Android Your content must have a ListView whose id attribute is ‘android.R. id.list ‘solutions to errors
Listview plays an important role in Android development, and it is used in many occasions
Error prompt: your content must have a listview which ID attribute is’ Android. R id.list ‘
For the above error, it may be that we inherit liseactivity to monitor setonitemclick events in listview, but there is no listview tag. It has been said on the Internet that we only need to add the following code to the layout file:
<ListView
a<ListView android:id= “@ Android: ID/list” or android:id= “@id/ android:list ” android:layout_ width=”fill_ parent” android:layout_ height=”wrap_ content”&> </ListView&>
ndroid:id= “@ Android: ID/list” or android:id= “@id/ android:list ”
android:layout_ width=”fill_ parent”
android:layout_ height=”wrap_ content”&>
</ListView&>
However, if we want to implement a custom listview, that is, we will monitor the space in the listview through the baseadapter, then we just need to inherit the activity. But note that we use listview instead of inheriting listactivity. Therefore, we must remember to declare a listview object in the project and instantiate it, so that we can get the listview we want
Don’t worry. Don’t forget that we have our own instantiated listview. With this, we can call the setonitemclicklistener method. The details are as follows:
listView.setOnItemClickListener (new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?&> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Log.i(“TAG”,”The Item has been clicked”);
}
});
listView.setOnItemClickListener (new OnItemClickListener() { @Override public void onItemClick(AdapterView<?&> arg0, View arg1, int arg2, long arg3) { // TODO Auto-generated method stub Log.i(“TAG”,”The Item has been clicked”); } });
At this time, we can still use the same construction method as the simpleadapter provided by the system to call our own customized baseadapter, as described before
Similar Posts:
- [Solved] Java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
- Eclipse’s shortcut Ctrl + Shift + F doesn’t work
- Flutter ListView Error: RenderBox was not laid out: RenderViewport#680c1 NEEDS-LAYOUT NEEDS-PAINT
- [Solved] android.view.InflateException: Binary XML file line #0: Error inflating class ImageView
- Ffmpeg scaling — the solution of “width / height not divisible by 2”
- UICollectionView must be initialized with a non-nil layout parameter [Solved]
- Elimination of warning message “nested weights are bad for performance”
- [Solved] echart Error: Can’t get dom width or height
- Android: layout layout page can not be displayed, prompt: one or more layouts are missing the layout_width or layout_height attrib…
- A problem with 0 document. Documentelement. Clientwidth