我有一个 ListView,它的 id 是 android:id="@android:id/list"
我有一个自定义光标适配器,我在其中扩展了我的自定义线性布局 我的自定义 LinearLayout 在左侧有一个 ImageView ,在右侧有一个 TextView
我能够在 ListView 中填充数据,但我无法让 setonItemClickListener 工作
PlaylistScreen.this.lv = getListView();
MusicCursorAdapter musicCursor = new MusicCursorAdapter(PlaylistScreen.this, cursor, tracks);
//PlaylistScreen.this.setListAdapter(musicCursor);
PlaylistScreen.this.lv.setAdapter(musicCursor);
PlaylistScreen.this.lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Log.d("Item Click","+++++++++");
})
})
but i am not able to get this in logcat
最佳答案
我通过重写光标适配器中的 getView 方法并为 View 实现 onclicklistener 来实现这一点。谢谢大家的建议
关于android - ListView onItemclickListener 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6706787/