Skip to content Skip to sidebar Skip to footer

Showing Recursive Lists Inside A Tab View

Algorithm question here. I'm creating an app that shows a legal document, with tabs for navigation (TOC, bookmarks, etc). Inside the TOC tab, I need to show a multilevel table o

Solution 1:

Okay. Number one you cannot put ListViews inside ListViews, ScrollViews, GridViews or anything scrollable for that matter (i.e. a ListView item cannot be ListView). It might compile, it might run, but the results will not be what you expect or want. This is because a ListView cannot have a height which is set to WRAP_CONTENT.

You can have a two-level list (ExpandableListView) but if you require more levels than that you will have to implement the functionality yourself by extending ListView or ExpandableListView.

You can also have sectioned lists, and lists with multiple item types, but there is no way using the default SDK components to get a 5-level list.

Number two: Yes you can have a ListView inside a TabHost. You won't be able to use a ListActivity, but that just means you'll have to call the ListView methods directly:

ListViewmyList= findViewById(R.id.myList);
myList.setAdapter(myListAdapter);

instead of calling the inbuilt ListActivity methods.

Just place your ListView inside the FrameLayout in your layout file. If you have three tabs and the ListView is the first element inside the FrameLayout, then it will be displayed as the content for the first tab. If it is the second element, it will be the content for second tab and so on.

The only way you could implement a recursive list with inbuilt components would be to use a single ListView, and then change the contents of the adapter of the ListView when a user selects an item (essentially a drill-down menu using a single ListView). You'd also need to catch the back button with onBackPressed in order to allow the user to navigate back up the list, or provide a back button somewhere.

Post a Comment for "Showing Recursive Lists Inside A Tab View"