简体   繁体   中英

Nested ListView - ListView in ListView

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.

在此处输入图片说明

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:

在此处输入图片说明

... 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!

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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM