I need to have a List in an Activity that is in a TabHost. The list gets opened when a button is clicked. I however want the new activity to open up and keep the tabs on top, so I created a class, TabActivityGroup, that extends the ActivityGroup and each of my activities extend TabActivityGroup. How would I create a list without extending ListActivity as I cannot extend two classes.
Asked
Active
Viewed 652 times
2 Answers
2
Do not use ListActivity. Just use a regular activity. In the layout file do the following:
Give the list an id
<ListView
android:id="@+id/name_of_list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
Inside your activity use:
ListView listView = (ListView)findViewById(R.id.name_of_list);
mAdapter = new SomeSortOfAdapter(this, items);
listView.setAdapter(mAdapter);
Now you can make your activity be ActivityGroup :)

Uriel Frankel
- 14,304
- 8
- 47
- 69
-1
Hmm, I suspect you're going about this the wrong way. Check out the Tab Layout example. What you want to be able to do is add some subclass of the ListView as a subview of the TabHost view rather than having multiple inheritance. I'd suggest reading through that tutorial and rethinking how you're structuring your app.

Chris Thompson
- 35,167
- 12
- 80
- 109