android: having two listviews in two listactivities didn't work
- by Yang
I guess my previous question wasn't clear enough (http://stackoverflow.com/questions/2549585/android-failed-to-setcontentview-when-switching-to-listactivity), so I explain as follows.
In my app I have two listactivities which uses two different listviews:
public class Activity1 extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
try{
super.onCreate(savedInstanceState);
setContentView(R.layout.listview1);
}
public class Activity2 extends ListActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
try{
super.onCreate(savedInstanceState);
setContentView(R.layout.listview2);
}
}
As required by android, listview must have an ID which is exactly "@android:id/list". If I set the listview in both listview1 and listview2 with the same ID, then they will end up using the same format of listview, which is not what I want. But if I set one of the IDs to be sth like "@+id/listview2", android gave me the error:
java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
How do I handle this dilema?