Saturday, October 16, 2010

[android-developers] Your content must have a ListView whose id attribute is 'android.R.id.list'

I am getting this error- Your content must have a ListView whose id
attribute is 'android.R.id.list'
my xml file is

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>

<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:text="@string/footer"
android:padding="4dip"
android:background="#FF666666"
/>
</LinearLayout>

and .java fiile is like

public void onCreate(Bundle savedInstanceState)
{
System.out.println ("First stmt in onCreate of AddRoom");
super.onCreate(savedInstanceState);
setContentView(R.layout.addroom);

String[] rooms = getResources().getStringArray(R.array.Room_array);
// By using setAdpater method in listview we an add string array in
list.
ListView list = (ListView)findViewById(R.id.list);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.listitem, rooms);
list.setAdapter(adapter);
registerForContextMenu(list);


}

and error is at line 19 which is- setContentView(R.layout.addroom);
what is wrong?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate