Android onClickListener的奇怪行为

| 我正在尝试在我的ExpandedListView上设置一个子级单击侦听器,并且得到一些奇怪的结果:
theList.setOnChildClickListener(new OnChildClickListener() {
    @Override
    public boolean onChildClick(ExpandableListView parent, View view, int groupPosition, int childPosition, long id) {
        Log.i(LOG_TAG, \"clicked\");

        ExpandableListAdapter adapter = parent.getExpandableListAdapter();
        View v = (View)adapter.getChild(groupPosition, childPosition);

        Toast toast = Toast.makeText(getApplicationContext(), 
                \"item: \" + new Integer(groupPosition).toString() + \":\" + new Integer(childPosition).toString(), 
                Toast.LENGTH_SHORT);
        toast.show();

        if (!((CheckedTextView)view.findViewById(R.id.check)).isChecked()){
            ((CheckedTextView)view.findViewById(R.id.check)).setChecked(true);
        } else {
            ((CheckedTextView)view.findViewById(R.id.check)).setChecked(false);
        }

        return true;
    }
});
这样的作品。但是,当我检查其中一个项目时,似乎还会随机选择另一个项目。我这样做不正确吗?     
已邀请:
我自己解决了这个问题。我最终扩展了适配器类,并覆盖了getChildView和getGroupView,并向适配器添加了一个布尔值列表,以跟上复选标记。可能不是最复杂的解决方案,但是效果很好。     

要回复问题请先登录注册