How to use nested Listview in android

≡放荡痞女 提交于 2019-12-12 05:26:25

问题


I need to show data which contains a main object and has many child objects. Each child object has its view which contains checkbox and buttons having functionality. Giving demo design which I've done

http://i.stack.imgur.com/ELB51.png

But am not understanding how to create nested listview to populate data in this way. Picture showing 'Reminder 01' is first reminder data and there will be many reminder data each having their own doses data with checkbox and snooze button. Even I've done all logic and getting data but don't know how to populate data in nested listview. Please give me efficient suggestion.


回答1:


You can use Cards Lib

Examples:

  • Card With List
  • Cardexpand-And-CardListView

And you can customize the card's internal layout to use according to what you need.




回答2:


You need an ExpandableListView backed by an ExpandableListAdapter. Here is a sample ExpandableListAdapter from an app that I worked on for practice sometime back (simply use it as an example as it was not designed with efficiency in mind) - Sample ExpandableListAdapter. You can go through the layouts to see how I used them.

You will go about the same as you would by binding a normal ListView to an instance class that extends BaseAdapter but instead you will bind your ExpandableListView to an instance of a class that extends BaseExpandableListAdapter.



来源:https://stackoverflow.com/questions/29306500/how-to-use-nested-listview-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!