折叠可扩展列表组时,数组索引超出范围

时间:2013-02-11 11:56:37

标签: android expandablelistview

我正在使用可扩展列表视图并使用expand.collapse将其折叠但是它抛出异常 - Arrayindexoutofbound。

ExpandableListView  mExpandableList.setOnGroupClickListener(new OnGroupClickListener() {

                @Override
                public boolean onGroupClick(ExpandableListView parent, View v,
                        int groupPosition, long id) {
                    // TODO Auto-generated method stub

                    if(pause!=1234){

                        mExpandableList.collapseGroup(pause);
                    System.out.println(pause+" CLICKED");
                }
                    pause=groupPosition;
                    return false;
                }
            });

1 个答案:

答案 0 :(得分:0)

你可以这样用吗

@Override
            public boolean onGroupClick(ExpandableListView parent, View v,
                    int groupPosition, long id) {
                // TODO Auto-generated method stub

                if(pause!=1234){

                    mExpandableList.collapseGroup(groupPosition);
                System.out.println(pause+" CLICKED");
            }
                pause=groupPosition;
                return false;
            }

或者如果它适合您的情况,请使用此方法。

mExpandableList.setOnGroupExpandListener(new OnGroupExpandListener() {
        public void onGroupExpand(int groupPosition) {

        }
    });