可扩展的ListView [英] Expandable ListView

查看:146
本文介绍了可扩展的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);
            }
        }
    }

});

这篇关于可扩展的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆