How to keep the ExpandableListView Opened?

David Brown picture David Brown · Aug 8, 2011 · Viewed 17.9k times · Source

I am working on the ExpandableListView I have completed the work, now only one thing that I want to do is I don't want the ListView to be DropDown on click of the Expandable List View rather I want to show it opened with all the Items displayed inside without performing any click on them.

Can anyone tell me how can i do that particularly.

Answer

A. Abiri picture A. Abiri · Aug 8, 2011

Do this for every one of the groups to expand them:

listView1.expandGroup(int groupPosition);

If you want to prevent group collapse, then do this:

listView1.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener()
{
    public boolean onGroupClick(ExpandableListView arg0, View itemView, int itemPosition, long itemId)
    {
        listView1.expandGroup(itemPosition);
        return true;
    }
});