0

I tried to found a method, but no results. I want a ListView like below, and when I click on an element, like "Word", it'll be like this picture :

And the result I want

Is it possible ?

TZHX
  • 5,291
  • 15
  • 47
  • 56
toshiro92
  • 1,287
  • 5
  • 28
  • 42
  • Surely possible , For first Pic, you need to create custom adapter by extending baseAdapter class – AAnkit Jul 09 '12 at 16:33
  • Yep it is easy to make, but for the second picture ? (i changed my post because it is not clear :/) – toshiro92 Jul 09 '12 at 16:35

2 Answers2

2

What you described is what an ExpandableListView does. Basically it's like a listview so you'll still have to create your own adapter, but it lets you click a row to inflate a bigger item that you can then stuff your text into.

Frank Sposaro
  • 8,511
  • 4
  • 43
  • 64
1

I would recommend creating your own class that extends ArrayAdapter or BaseAdapter. Then you can make use of the getView() method that gets called every time the screen gets redrawn for the user. You can then design multiple views for each selection and choose which one to display in the getView() function. So when the user selects an item, you set a flag in your custom class, and then notifyDataSetChanged() and you're good to go!

Joel
  • 4,732
  • 9
  • 39
  • 54
  • This is definitely the best/easiest way to do it. For more information on how to make your own lists with ListView and ArrayAdapter, check out this link: http://www.ezzylearning.com/tutorial.aspx?tid=1763429 – Sam Stern Jul 09 '12 at 17:40
  • 1
    Too cumbersome. `ExpandableListView` is made for this very purpose, as mentioned in Frank's answer. – Dheeraj Vepakomma Jul 09 '12 at 17:47