ExpandableListView组视图展开默认值

Nik*_*hil 36 android expandablelistview

我完美地开发了ExpandableListView.

在我的ExpandableListView中有五个组.加载第一次然后崩溃所有五组.这是默认的.

现在我的问题是加载第一次expandablelistview当时2组扩展,其他3组崩溃.

所以请指导我该怎么办?

Nik*_*hil 105

现在我得到了解决方案,它将完美地工作..请使用此..

ExpandableListView Exlist;

Exlist.expandGroup(0);
Exlist.expandGroup(1);
Run Code Online (Sandbox Code Playgroud)


bhe*_*man 75

我根据Nikhil的回答制作了这个片段.认为其他人也可能觉得它很有用.仅在使用BaseExpandableListAdapter时才有效.ELV

ExpandableListView elv = (ExpandableListView) findViewById(R.id.elv_main);
elv.setAdapter(adapter);
for(int i=0; i < adapter.getGroupCount(); i++)
    elv.expandGroup(i);
Run Code Online (Sandbox Code Playgroud)


小智 6

这是一个完美的解决方案,它会自动增加

ExpandableListView elv = (ExpandableListView) findViewById(R.id.elv_main);
elv.setAdapter(adapter);
for(int i=0; i < adapter.getGroupCount(); i++)
    elv.expandGroup(i);
Run Code Online (Sandbox Code Playgroud)

但这是基于项目位置

ExpandableListView Exlist;
Exlist.expandGroup(0);// first item of listview
Exlist.expandGroup(1);//second item of listview
Run Code Online (Sandbox Code Playgroud)