質問

I'm an android dev beginner and I know the basics of a simple list view.

But what I need to do now is (I think) pretty advanced, so please tell me how (or if?) this is possible:

I have different dates and for each date, a different set (even a different count) of attributes. These attributes are created by the user dynamically. This is the structure:

07.09.2012 - Weight: 10
07.09.2012 - Fat: 20
07.09.2012 - Muscles: 30

08.09.2012 - Weight: 20

09.09.2012 - Weight: 30
09.09.2012 - Water: 10

etc.

I need to present this information in a clearly arranged / simple way, so I thought about a custom listview which could look like:

LIST:

07.09.2012
+ Weight: 10
+ Fat: 20
+ Muscles: 30
08.09.2012
+ Weight: 20
09.09.2012
+ Weight: 30
+ Water: 10

It would be event better if only dates are shown first and the additional information below the date is collapsed but expandable.

Is this possible? Can you point me to some code examples / provide me some code? IF this is not possible or hard, or you have a better idea of visualizing this dynamic information, can you tell me a better way?

Thanks!

役に立ちましたか?

解決

You are probably looking for ExpandableListView . Here is an example how to use it.

If you don't want/need expanding and collapsing you can create a Layout for the items (in your case the date) and you can set the visibility for things not shown for the date (e.g. Water) to View.GONE. This way they won't take any space on the screen.

Lastly, you could simply use a ScrollView and put all the items in there. This, is however only acceptable if you know you will not have a lot of items, because ListView is optimized.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top