0

我使用下面的代码进行设置onGroupClickListenerMainActivity并且还设置了我的自定义适配器中的OnLongClickListener视图,名为.getGroupView()MyExpandableListAdapter

然后,当我运行程序时,onGroupClickListener从不触发我从返回 true 或 false OnGroupClickListener()。如果我OnlongClickListenergetGroupView()程序中删除正常运行onGroupClickListener()并将触发!这里发生了什么以及如何解决?

如果不是,则意味着无法设置longClickListener为一组ExpandableListView?!!!这是OnGroupClickListener()MainActivity中的代码

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;               
        }

    }); 

这是 MyExpandableListAdapter 中长按的代码:

arg2.setOnLongClickListener(new OnLongClickListener(){

        @Override
        public boolean onLongClick(View view) {
            DetailDialog.getDialog(screen.getContext(),(String)getChild(arg0,5));
            return true;
        }

    });
4

1 回答 1

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;               
        }

    }); 
于 2013-09-11T11:37:26.510 回答