关于解决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″?>
<TabHost
android: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。