我有这样的ListView声明:
<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
我已经将ListView的id
字段设置为@id/android:list
,但没有得到错误Your content must have a ListView whose id attribute is 'android.R.id.list'
。
这完全错了,我的朋友。
在android:id
属性中,您需要为小部件定义自己的id。所以,如果你想给id作为列表,那么它会像:
android:id="@+id/list"
android:list将指向android库中id为list的变量。
您给出的id不正确。
用途:android:id="@+id/listView"
当您创建一个新的视图时,您应该使用+来给出id。