0

我正在使用可扩展列表视图并使用 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;
                }
            });
4

1 回答 1

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) {

        }
    });
于 2013-02-11T12:30:37.750 回答