Populating a list view from another list view

不问归期 提交于 2020-01-07 02:18:10

问题


I need to achieve this: I have a sqlite table with this data

slno Type   Level_1 Level_2      Level_3
1 Animals   Cat     Null         /sdcard/Video
2 Animals   Cat     Null         /sdcard/PDF
3 Birds    Aves     HummingBird  /sdcard/video

I should have a list view with Animals and Birds , clicking on Animals shows me Cat, while Bird shows me Aves. Then so on until the content - which has to be played depending on the type. Now this can be achieved by creating a lot of Activities say for Animals level - pass level_1 for Activity_2 and so on and get the list views. But in my case the levels may not be fixed - there might be a level_4 coming in where there is content - so the activity creation has to be dynamic and cannot be static - how can this be achieved ?


回答1:


No need to create lots of activity.If understand your problem completely then i will suggest you go for Expandable List View like in image

This link has best tutorial for this design Go through it




回答2:


Just Use only One activity, and Set this Activity's Data Source on calling activity, like

intent.putExtra("KEY", DataSource);

in onCreate() method get this DataSource from intent, like

intent.getParcelableList("KEY");

and start this activity only with new data source, or play the file according to the level.




回答3:


Implemented by modifying the base adapter to include multiple levels.



来源:https://stackoverflow.com/questions/8891006/populating-a-list-view-from-another-list-view

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