java – 在mainActivity类中未检测到自定义布局?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – 在mainActivity类中未检测到自定义布局?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1139字,纯文字阅读大概需要2分钟。
内容图文
![java – 在mainActivity类中未检测到自定义布局?](/upload/InfoBanner/zyjiaocheng/804/46919c39b8254f23b308603d30d58ec3.jpg)
我是android的初学者.
我正在使用Android Studio 1.0.我正在尝试为listView创建自定义布局.我在名为row_layout的res / layout中创建了自定义布局文件.布局的xml是这样的:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cl_textView"
android:textSize="30sp"
android:textStyle="bold"
android:padding="15dp"/>
</LinearLayout>
在MainActivity类中实现该自定义布局的代码是:
ListAdapter theAdapter = new ArrayAdapter<String>(this, android.R.layout.row_layout,toDoList);
但是活动类没有检测到此自定义布局,并在构建时显示以下错误.
解决方法:
R.layout表示由您的应用程序提供的资源.可以通过R访问由您的应用程序定义的所有变量,资源文件(可绘制,字符串,布局等).
示例R.layout.*,r.drawable.*,R.id.*,R.color.*等
但是android.R表示你的android SDK的资源.如果你使用android.R,你可以使用所有未由你定义但由android SDK定义的资源
在你的代码中,你使用自己的布局,所以用R.layout替换android.R.layout
内容总结
以上是互联网集市为您收集整理的java – 在mainActivity类中未检测到自定义布局?全部内容,希望文章能够帮你解决java – 在mainActivity类中未检测到自定义布局?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。