I have an array of strings which I want to display using a ListView.
I checked online and found that it can be done by extending my class from ListActivity.
But I am facing a problem.
In my application I have already inherited TabActivity.
Now, I cant inherit multiples classes.
What do I do now ?
I need to keep the tabs and also generate the strings in the ListView.
All suggestions are welcome.
I have an array of strings which I want to display using a ListView.
Share
Fortunately, you don’t need to inherit from
ListActivityto use aListView. The only thing inheriting fromListActivitybuys you is that it automatically finds aListViewin your layout with an attributeandroid:id="@android:id/list", and adds a helper method for setting the list’s adapter (along with some other helper methods which are accessible on theListViewitself).So, in your case, since you can not inherit from multiple classes, you can keep the super class of
TabActivityand simply callfindViewByIdto find yourListView, and then call setAdapter on yourListViewmanually.