Skip to content Skip to sidebar Skip to footer

Eclipse / Android Error

So I'm getting 3 errors 'final int sortColumnIndex = c.getColumnIndex(YOUR_SORT_COLUMN_NAME);' & 'public class MyAdapter extends CursorAdapter implements SectionIndexer' <--

Solution 1:

According to your Logcat:

Unable to start activity ComponentInfo{testing.android.application.three/testing.android.application.three.MainActivityNext}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'

Whenever you use or extend a listactivity the view you build for it must have a listview with that id.

<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingLeft="8dp"android:paddingRight="8dp"><ListViewandroid:id="@android:id/list"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#00FF00"android:layout_weight="1"android:drawSelectorOnTop="false"/><TextViewandroid:id="@android:id/empty"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#FF0000"android:text="No data"/></LinearLayout>

See http://developer.android.com/reference/android/app/ListActivity.html for more info on it.

Solution 2:

as in log:

our content must have a ListView whose id attribute is 'android.R.id.list'

means you will need to use @id/android:list id in xml for ListView. do it as:

<ListView android:id="@id/android:list"  
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
         ..../>

Solution 3:

If your activity extends the ListActivity then you have to set the id of the xml of your ListView like below

< ListView
    android:id="@android:id/list"
...

Post a Comment for "Eclipse / Android Error"