I want to design my app. with more modularity. In my app most of the screens are ListViews, and with similar list items.
For eg. I have 3 ListViews, each for a different category. (Music list, Audi list, Video list) and 1 Main view, that list latest 2 list items of each category.
My Plan is to reuse the 3 inner ListViews on my Main view as as list items.
If you want to have a multi-list view (each item having or not a subitem), you can use an ExpandableListView.
I am not completely sure if that's possible but the first thing I would try is an ExpandableList.
Check this so question:
How to add image in expandable List in parent in android?
Related
I’m trying to implement three level list views where only the top level is required to be scrollable. Example of the UI is as below:
List view 1: List of houses : scrollable
List view 2: List of rooms in houses : Not scrollable
List view 3: List of windows in the rooms : Not scrollable
Important thing is that the data I fill up needs to be dynamic. So the number of items in the list view 2 and 3 can be changed.
I don’t want list view 2 and 3 as scrollable as they are not going to have too many items, and I want them to be displayed always. Therefore, only top level list view is required to be scrollable.
I tried with 3 level expandable list views but I really don’t need expandable list views as they increase the number of clicks to view all the information at one time.
I tried is to add ListView within ListView and adding adapter to add items in the low level list views. But its not working. It displays only top level list view but the child list view is not displayed at all.
Is there any way to add ListView within ListView as above?
If there is not much item in listview 2 & 3 then do not use listview for level 2,3.
Use a listview for 1, LinearLayout for 2 & 3 and add textView dynamically to those layouts.
Put 2,3 layout to another linear layout and align it to bottom ... so remaining place above those view will be covered by listview.
Comment if my answer is not clear or you need more explanation.
I have a listview with 5 items. Each item has a listview with 5 items. I would like to have this in a single activity using adapter. Is it possible?
Expandable lists let you create lists within lists.
They’re ideal for list items that have sub-categories. The user selects an item from a scrollable list and another list pops open. They can then make another selection from this list. Here is the example and tutorial about this:
http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/
You can use the Expandable lists.
it will help whatever you want like in your main listview have 5 item and each item have number of more item it will child of that item.
I am making an app in which the 1st layout contains clickable List having 12 items
and on clicking of each item, the user goes to a new Activity that has Expandable list View.
And I have concerned the tutorial at https://www.youtube.com/watch?v=BkazaAeeW1Q
and do I need to make 12 Activities each containing an Expandable View or is it possible that one Activity containing 12 Expandable Views but only one Expandable view is visible at a time (and which among them is visible will be dependent on Item clicked on the List View of 1st layout)
Hope I am able to make my point clear?
Use List Fragment, by using fragment no need to create 12 activity ,you just replace the container with view.
Also we can make one expandable view at one time, check on child click and onGroupexpand method for that.
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 of contents. At the 'leaf' of the toc, I need to show a TextView
So, I could have:
tab1: List -> List -> List -> List -> List -> TextView
or
tab1: List -> List -> List -> TextView
or
tab1: List -> TextView
depending on the chapter, section, subsection, subsubsection structure of the book I'm showing.
Now, it doesn't matter how deep you are, the TabHost needs to be ALWAYS PRESENT, to provide the main navigation. (Yes, I asked, and I need to use the tabs, not a menu.)
The question:
How do you implement the recursive List inside the FrameLayout of a tab? Or should I use a ListView styled as tabs and just not use the TabHost?
Ideas?
Thanks!
llappall
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:
ListView myList = 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.
I have 2 ListView in a layout. I want each ListView show all their items. And scroll the whole layout.
A answer from one of the ListView Developers from the GoogleIO is: Never put a ListView in a ScrollView. This means if you want a ListView that is not scrolling as you are trying to do you maybe don't need a listview at all.
You could create a ListView put a Linearlayout in it and use the Adapters from the two Listviews to manually add the items of the list via linearlayout.addView Now you have one scrollable view that contains all items of the list. Because there is no recycling and only loading of the items in the list this is very inefficient and only usable if you don't have that much items.
The second more complicated way that you can go if you have say 20 items in each list is to use a custom adapter that takes the two listadapters and let you put all the items in one list.