1

ExpandableListView があり、すべて問題ありません。以下のように、子行をクリックしたときに切り替えたい各子行にチェックボックスがあります。

expandableListView.setOnChildClickListener(new OnChildClickListener() {
    @Override
    public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
        CheckBox checkBox = (CheckBox) v.findViewById(R.id.checkBox1);
        checkBox.toggle();
        return true;
    }
});

問題は、プログラムが onChildClick() イベント ハンドラ内に入らないことです。何か案が?

4

3 に答える 3

5

これを試して、

チェックボックスに設定android:focusable=falseします。それでもうまくいかない場合は、追加します。

android:descendantFocussability=blocksDescendants一番上のレイアウトに。

于 2012-12-03T13:39:12.320 に答える
1

有効にすることを忘れないでください

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    // TODO Auto-generated method stub
    return true;
}
于 2014-10-20T12:48:16.750 に答える