解决Your content must have a ListView whose id attribute is ‘android.R.id.list
16lz
2021-01-23
关于解决Your content must have a ListView whose id attribute is ‘android.R.id.list’的问题:
很可能是因为我们要实现对ListView中setOnItemClick的事件监听而去继承了LiseActivity,但是却没有ListView的标签,解决问题方法很简单:
ListView的id设置为“@android:id/list”或android:id=”@id/android:list”
用getListView来获取ListView的对象了。
在开发的过程中还会遇到类似的问题比如:TabHost
错误信息为:Your content must have a TabHost whose id attribute is ‘android.R.id.tabhost’
添加android:id=”@android:id/tabhost”, 这样就可以了。
还会遇到这样一个错误描述:Your TabHost must have a TabWidget whose id attribute is ‘android.R.id.tabcontent’
同样解决方法为:修改FrameLayout添加id属性
格式android:id=”@android:id/tabcontent ”
完整的参考一下:
<?xml version=”1.0″ encoding=”utf-8″?><TabHostandroid:id=”@android:id/tabhost”xmlns:android=”http://schemas.android.com/apk/res/android”android:layout_width=”fill_parent” android:layout_height=”fill_parent”><LinearLayout android:id=”@+id/user″ android:layout_height=”fill_parent”android:layout_width=”fill_parent” android:orientation=”vertical”><TabWidget android:id=”@android:id/tabs” android:layout_height=”wrap_content”android:layout_width=”fill_parent”>TabWidget><FrameLayout android:id=”@android:id/tabcontent” android:layout_width=”fill_parent”android:layout_height=”fill_parent”>FrameLayout>LinearLayout>TabHost>
注意:一个工程中只能有一个TabHost。
更多相关文章
- 有关Android中EditText的一些属性
- Android自定义属性,format详解
- Android 错误 :TextView中属性ellipsize的 值为start、middle可能
- android实现Parcelable序列化对象
- Android Intent传递对象和集合
- android中的一个属性动画,可以显示更多的一个案例
- RelativeLayoutd 的属性
- android intent 传递对象需要序列化实现Parcelable接口
- Android 属性动画中心点无限循环