Tag Archives: have

Android Your content must have a ListView whose…

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