无法显示多级可扩展列表视图的最少节点

时间:2014-03-26 11:37:15

标签: android expandablelistview

我有4级元素的可扩展列表视图,当我点击最后一个要扩展的元素时,它根本不会展开,我甚至看不到一个项目,但它有更多的项目。

我尝试动态设置布局高度,但我不知道如何获得真正的子项目高度

提前致谢!

1 个答案:

答案 0 :(得分:1)

设置类似的侦听器:

int lastExpandedGroupPosition;

    // Listview Group click listener
        expListView.setOnGroupClickListener(new OnGroupClickListener() {

            @Override
            public boolean onGroupClick(ExpandableListView parent, View v,
                    int groupPosition, long id) {
                return false;
            }
        });

        // Listview Group expanded listener
        expListView.setOnGroupExpandListener(new OnGroupExpandListener() {

            @Override
            public void onGroupExpand(int groupPosition) {

                if (groupPosition != lastExpandedGroupPosition) {
                    expListView.collapseGroup(lastExpandedGroupPosition);
                }
                lastExpandedGroupPosition = groupPosition;

            }
        });

        // Listview Group collasped (Close) listener
        expListView.setOnGroupCollapseListener(new OnGroupCollapseListener() {

            @Override
            public void onGroupCollapse(int groupPosition) {

            }
        });

        // Listview on child click listener
        expListView.setOnChildClickListener(new OnChildClickListener() {

            @Override
            public boolean onChildClick(ExpandableListView parent, View v,
                    int groupPosition, int childPosition, long id) {
                switch (groupPosition) {
                case 0:
                    switch (childPosition) {
                    case 0:

                        break;

                    default:
                        break;
                    }
                    break;

                case 1:
                    switch (childPosition) {
                    case 0:

                        break;

                    default:
                        break;
                    }
                    break;

                default:
                    break;
                }
            }
        });