Reputation: 249
I have created one list view.. it is having 5 items...
Now I want split the list items...
when user clickon the first listitem or focus on first item then immediately it has to show followed some text views or other things..but it has to show same list..
and agian same when he clickon or focus on the second item that first item has to be close and second item has to act some thing....
Upvotes: 2
Views: 906
Reputation: 128428
I think you need to implement the concept of "Expandable Listview", so that the clicking on one item, it will be expanded with their sub-items.
Refer the android-sdk page of Expandable ListView: http://developer.android.com/reference/android/widget/ExpandableListView.html
For having an example, check this site: http://mylifewithandroid.blogspot.com/2008/05/expandable-lists.html
Pls, check the below image, do you want to perform as same ????
If you want to do the same, it is already given in the "API-Demos" at Views/Expandable Lists/1. Custom Adapter
.
Enjoy !!
Upvotes: 2
Reputation: 10023
The problem is that you cannot use the standard ListView in your case, because in the standard ListView, the View of each row has to be one TextView. In your case, you need it to be at least two TextViews (The standard Text, and the one that's gonna show up onClick/onFocus).
You have to create your custom ListAdapter, and override the getView() function. Here is a code snippet that shows how to do it properly: Custom Adapter
In the getView(), you have to inflate the XML file that describes your List Row, and return it. In your case, I believe your XML file should contain 2 TextViews, one visible and one invisible.
Then, to handle the clicks, you can set a onItemClickListener on your ListView in your Activity class. The best way may be to have your Activity class implementing onItemClickListener, and to use this onItemClickListener to handle those. In the onClick() function, you just have to set the Visibility of your hidden TextView to VISIBLE.
Upvotes: 0
Reputation: 18348
You need to build custom rows, and handle showing more text on each row, there is no easy magicall way of doing it, but inflating your own rows, and setting a couple of attributes visibility isnt all that hard either.
Upvotes: 0