MY mENU


Thursday 2 May 2013

Error: Your content must have a ListView whose id attribute is android.R.id.list


When you are creating A ListVIew Item in Android and want to display your selected item on Toast message. When you are running that app and if you get an error like below.

"Your content must have a ListView whose id attribute is android.R.id.list"

For the above problem answer is.

If your are using ListActivity then you must have ListView in your xml of layout and must be id of 

ListView is android.R.id.list

So must add listview in your layout like below code
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/android:list" />

In The Java Code it’l be get like this.

lv = (ListView) findViewById(android.R.id.list);