napster
napster

Reputation: 717

how to create view that expand & shrink on click?

I have to display list of items along with a plus(+) sign , on click of plus sign list should expand & on click again list should shrink

Upvotes: 3

Views: 1586

Answers (2)

Avi Kumar
Avi Kumar

Reputation: 4433

You can do this but would need to do more work as you want to show

name ,address and plus sign should changed to minus , you would require to make a custom list view and what you can do is use

when plus button is clicked in list

 nameText.setVisibility(View.VISIBLE);                                

adress.setVisibility(View.VISIBLE);

btn.setBackgroundResource(R.drawable.minus);

and when minus button is clicked

nameText.setVisibility(View.GONE);

adress.setVisibility(View.GONE);

btn.setBackgroundResource(R.drawable.plus);

Upvotes: 2

10s
10s

Reputation: 1699

If you want to create a tree view like windows, then it is not a UI element that is supported by android. The similar to this is the ExplandableListView element.

Although in one business application I have found this http://code.google.com/p/tree-view-list-android/ project that does exactly what you want.

Upvotes: 1

Related Questions