setOnItemClickListener not responding [duplicate]

2020-04-18 07:54发布

Possible Duplicate:
setOnItemClickListener not getting called

I have a custom adapter which extends base adapter. When I set setOnItemClickListener in onCreate and implement onItemClick I'm getting no response when I click on a row.

     ListView lv = (ListView)findViewById(R.id.list);
     adapter = new ModuleAdapter(this);
     lv.setAdapter(adapter);
     lv.setOnItemClickListener(this);

after onCreate:

     @Override
     public void onItemClick(AdapterView<?> parent, View view, int position,
        long id) {

   Log.v(TAG, "clicked");

     }

There are only text views in my rows. Can anyone help please?

标签: android
2条回答
Explosion°爆炸
2楼-- · 2020-04-18 08:39

If you want to use

lv.setOnItemClickListener(this);

you must implement OnItemClick listener to your Activity.

and also you can use @user1597833 's answer.

if you want to click textview not cell, try @jeet 's answer.

查看更多
我只想做你的唯一
3楼-- · 2020-04-18 08:48

It seems views in the row item view, has focusable and clickable property true, so child of item take click event, instead of list row item, if it is the case, to solve this issue, change all view's of row item's focusable, and clickable property to false.

查看更多
登录 后发表回答