0

我有一个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;
            }
        });
    }
}
4

1 回答 1

0

您可以参考Expandable ListView Tutorial .. 本教程中给出的所有步骤和代码.. 您可以清楚地了解.. 一切顺利..

于 2013-10-09T09:33:12.313 回答