0

I've been experimenting with different types of "Lists" and instead of having just one type, I decided to make a ListView that can hold different types of ListView.

On my Custom View for a ListView I have a "Title(TextView)", "Splitter or Border(TextView)" and then the ListView. This way I can create a list with categories and not have them all look the same. In the List there could be another List with just Text, one with Images and Text, one with Images, Text and Buttons.

enter image description here

These two have their very own ListView's on them. I could change it to another ListView type by changing the adapter.

First of all, is this a good idea - performance wise?

Secondly, I've added multiple items to the first and the second list but they're not being shown. Just the first item in each lists are being shown. Why? Only the first item of each ListView inside the ListView is being shown. I guess it's not autoresizing to the items in the list. Is it possible or will it be like this?

This way, at least it'll be flexible to create say a "settings" page that can hold different types of settings and how to update/change/add them.

UPDATED with ExpandeListView:

enter image description here

... does appear to be the same!

In case someone missed it, right now there are 2 ListView's containing 1 ListView each. List #1 should be able to be "different", a list of EditText's for example in that List. So it does not work with a normal solution!

Deukalion
  • 2,516
  • 9
  • 32
  • 50
  • I know that putting several layouts in each other is "bad" performance wise, but the way I'm intending it is not to have a ListView in a ListView in a ListView in a ListView. Just this "type" of setup. – Deukalion Mar 01 '14 at 11:09

2 Answers2

0

I think using one Listview with multiple view types would help you in a better way than you really think. Take a look on the following tutorial http://logc.at/2011/10/10/handling-listviews-with-multiple-row-types/

Also, you can take a look on ExpandableListView and then get all parents expanded and disallow parents from closing. In such a way, you might get what you need.

Ahmed Zayed
  • 2,165
  • 1
  • 20
  • 21
  • Tried using an ExpandeListView, by having a "TextView" as title and a ListView as child - you can therefor add multiple ListView's to each group. But the same thing occurs, the ListView is not expanded to the size of it's content. And my solution looked better. Otherwise, if I'd just use an ExpandeListView with just one type it becomes the exact thing as a "normal" LIstView, only in groups and expandable. Not what I was looking for. – Deukalion Mar 03 '14 at 08:43
  • Check this, http://stackoverflow.com/questions/9386669/listview-in-scroll-view-my-scrollview-moves-to-top-of-listview-how-do-i-prevent/21803960#21803960 – Ahmed Zayed Mar 03 '14 at 18:11
  • Yeah, that worked. Thanks. Add it to your answer and I'll mark it. – Deukalion Mar 04 '14 at 07:27
  • ...or it worked for so long. Now when I add a couple of lists and then rotate the screen, the first "Item" in the ListView gets duplicated. I serialized the items, and restored them by saving it in the bundle and such... but the same thing occurs. Say I have 5 lists, #1, #2, #3, #4, #5... When vertical, all lists are visible. When horizontal, the #1-#3 are visible because they fit within the screen. The #4 and #5 becomes whatever #1 is. – Deukalion Mar 04 '14 at 10:41
  • I figured out your problem, when you use this non scrollable listview you will measure the window to draw for the list depending on its height and its width. However, when you change configuration this computation is not valid anymore. So, i'll think of using device screen configuration in onMeasure screen. – Ahmed Zayed Mar 04 '14 at 15:54
0

Your array adapter can inflate different views for different types of data

https://developer.android.com/reference/android/widget/BaseAdapter.html#getItemViewType(int)

is that what you're asking?

Brian
  • 4,328
  • 13
  • 58
  • 103
  • What I have is a "ListViewItemCategory" or so it's called. It consists of a TextView, a Border and a ListView. This is always the same. But the contents of that ListView should be flexible; so I can add any other type of list. And then add the ListViewItemCategory to it's own ListView. A "static" ListView with a specific item (Category) and inside the Category, any type of list can be added, or any type of adapter with it's own set of "style" can be added. So each list could look different. Instead of having a 100% page with just one type of list = lots of pages! – Deukalion Mar 04 '14 at 07:29
  • At least for a settings "Activity" this is a good way to categorize and to use different controls for changing the settings. – Deukalion Mar 04 '14 at 07:34