可扩展的ListView
问题描述:
我使用expandableListView的UI设计,所以我想知道Android的可扩展列表视图,有没有办法只允许一个列表项展开,即当您单击并展开一个项目,其他项目自动崩溃了。
I am using expandableListView for UI design, so I am wondering for Android expandable listview, is there a way to allow only one list item expanded, i.e. when you click and expand an item, all other items are collapsed automatically.
感谢
答
当你点击一个项目,你可以通过剩下的循环和折叠每个人除了一个你只需点击...
When you click one item you could loop through the rest and collapse each one except for the one you just clicked...
list.setOnGroupExpandListener(new OnGroupExpandListener() {
public void onGroupExpand(int groupPosition) {
int len = mAdapter.getGroupCount();
for(int i=0; i<len; i++) {
if(i != groupPosition) {
list.collapseGroup(i);
}
}
}
});