How to check if group is expanded or collapsed in Android ExpandableListView?

kyrax picture kyrax · Mar 6, 2015 · Viewed 11.5k times · Source

I'm looking for an api like isExpanded() or isCollapsed() that tell me if a group is expanded or collapsed.

Answer

IntelliJ Amiya picture IntelliJ Amiya · Jun 6, 2015

You can use isGroupExpanded .

 expListViewObj.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {

                @Override
                public boolean onGroupClick(ExpandableListView parent, View v,
                                            int groupPosition, long id) {

                    if(parent.isGroupExpanded(groupPosition))
                    {

                     // Do your Staff
                    }
                    else{

                       // Expanded ,Do your Staff

                    }


                    return false;
                }
            });

For more details you can visit Here

http://developer.android.com/reference/android/widget/ExpandableListView.html#setOnGroupClickListener(android.widget.ExpandableListView.OnGroupClickListener)