Vigneshwaran T
Vigneshwaran T

Reputation: 307

How to keep a child selection after collapse the expandable list view

How to keep a child selection after collapse the expandable list view. When the user selects one child in expandable list view after it collapse it will not shown ..

Upvotes: 1

Views: 595

Answers (1)

Ram Prakash Bhat
Ram Prakash Bhat

Reputation: 1308

Implement onChild click listenr in your fragment/Activity

set the listener like below

expandableListView.setOnChildClickListener(this);

Code snippet:

  @Override
    public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition, int childPosition, long id) {

        YourView yourView  = (YourView) view.findViewById(R.id.view_id);
        YourDataItem item = (YourDataItem) yourView.getTag();

        item.isSelected = !yourView.isChecked();

        yourView.setChecked(item.isSelected);

    }

Don't forget to setTag() in your adapter

Upvotes: 1

Related Questions