Reputation: 91
Can anyone tell me how I can hide(not collapsing all items) all the items in an expandable list view except for the one item which is clicked. Can this be done using the adapter class implementation? or Just by hiding the Expandable list view on it's item click and then showing the required view with just one item? My current implementation is done by hiding the view and showing the other one with just one item. Any other way to do this?
Upvotes: 1
Views: 698
Reputation: 407
You can do one thing:
List<String> items, selectedItem;
ExpandableListAdapter adapter;
view.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectedItem = new ArrayList<String>();
selectedItem.add(items.get(position));
adapter.notify(selectedItem);
}
});
I assume that you have list of string and you set items via ExpandableListAdapter.
Implement above in your fragment/activity.
Now, when user touch on any item, you will get that item and notify adapter with new list where there is only selected item, so other items will be hide.
Upvotes: 1
Reputation: 1924
Yes of course this will be done using the adapter class implementation.
Upvotes: 0