How to keep the ExpandableListView Opened?

匆匆过客 提交于 2019-12-03 15:54:26

问题


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.


回答1:


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



回答2:


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..!




回答3:


Open ExpandableListView Group:

 listView.expandGroup(itemPosition);

Collapse ExpandableListView Group:

 listView.collapseGroup(itemPosition);


来源:https://stackoverflow.com/questions/6978434/how-to-keep-the-expandablelistview-opened

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