android: having two listviews in two listactivities didn't work

Posted by Yang on Stack Overflow See other posts from Stack Overflow or by Yang
Published on 2010-04-18T20:50:36Z Indexed on 2010/04/18 20:53 UTC
Read the original article Hit count: 357

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about android

Related posts about listview