ExpandableListView不扩展

时间:2013-09-11 11:24:36

标签: android android-listview expandablelistview

我使用下面的代码在onGroupClickListener中设置MainActivity,我还设置了OnLongClickListener以查看名为getGroupView()的自定义适配器的MyExpandableListAdapter。< / p>

然后当我运行程序onGroupClickListener时,我从OnGroupClickListener()返回true或false。如果我从OnlongClickListener程序正常运行getGroupView()并{ {1}}会开火!这里发生了什么以及如何解决?

如果没有,则表示无法将onGroupClickListener()设置为longClickListener的组?!!!以下是MainActivity中ExpandableListView的代码

OnGroupClickListener()

以下是MyExpandableListAdapter中长按的代码:

exListView.setOnGroupClickListener(new OnGroupClickListener(){

        @Override
        public boolean onGroupClick(ExpandableListView parent, View v,
                int groupPosition, long id) {                               
            gallery.setAdapter(new ImageAdapter(getBaseContext(),(Bitmap[]) exListAdapter.getChild(groupPosition, 7)));             
            lastClickedGroup=groupPosition;                 
            return false;               
        }

    }); 

1 个答案:

答案 0 :(得分:0)

试试这可能会对你有所帮助

exListView.setOnGroupClickListener(new OnGroupClickListener(){

        @Override
        public boolean onGroupClick(ExpandableListView parent, View v,
                int groupPosition, long id) {                               
            gallery.setAdapter(new ImageAdapter(getBaseContext(),(Bitmap[]) exListAdapter.getChild(groupPosition, 7)));             
            lastClickedGroup=groupPosition;                 
            exListView.expandGroup(groupPosition);//UPDATE HERE
            return false;               
        }

    });