为什么我的可扩展列表监听器从未被调用过?

时间:2013-10-09 09:20:31

标签: android

我有一个ExpandableListView,我不知道为什么当我点击一个孩子时我的听众从未被调用过。这是我的代码:

public class MainActivity extends ExpandableListActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // ...

        this.getExpandableListView().setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {
                Log.v("test", "short");
                // not working when I click on a child
            }
        });

        this.getExpandableListView().setOnItemLongClickListener(new OnItemLongClickListener() {

            @Override
            public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                    int arg2, long arg3) {
                Log.v("test", "long");
                // not working when I click on a child
                return true;
            }
        });
    }
}

1 个答案:

答案 0 :(得分:0)

你可以参考Expandable ListView Tutorial ..本教程中给出的所有步骤和代码..你可以得到清晰的想法..一切都很好..