0

我正在使用自定义可扩展列表视图,并且适配器不在我的活动范围内。在我的活动中,我可以很好地设置 onclicklistener

    mTopicsExpandListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

        public boolean onChildClick(ExpandableListView parent, View v,
                int groupPosition, int childPosition, long id) {
            Log.i("MEAT", "This child row was clicked!");
            return false;
        }
    });

但是为了避免需要使用静态变量,在不久的将来,我希望能够在适配器本身中使用实现 OnChildClickListener

public class MExpandableListAdapter extends BaseExpandableListAdapter implements OnChildClickListener {
public boolean onChildClick(ExpandableListView parent, View v,
        int groupPosition, int childPosition, long id) {
    Log.i("MEAT", "This child row was clicked!");
    return false;
}

但后者什么也不做。第二种情况有什么不同吗?IsChildSelectable 设置为 true

4

1 回答 1

0

您仍然需要将新课程连接到:

在您的活动中,您需要:

mTopicsExpandListView.setOnChildClickListener(new MExpandableListAdapter());

你这样做了吗?

于 2012-10-05T08:46:38.173 回答