How to keep the ExpandableListView Opened?

夙愿已清 提交于 2019-12-03 05:22:21

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;
    }
});
Kailash Dabhi

Solution:- To Keep The Expandable list in Expanded mode all the times It is actually very simple you dont need to do anything but just put this one line in your getGroupView of your adapter and your expandablelistview always be in opened/expanded state:--

@Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {

        View v = convertView;
        your_expandableListview.expandGroup(groupPosition);
        return v;
    }

This works for sure... Enjoy..!

Open ExpandableListView Group:

 listView.expandGroup(itemPosition);

Collapse ExpandableListView Group:

 listView.collapseGroup(itemPosition);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!