Is it possible to use a OnItemClickListener on a ListView when the Items layout has a clickable/editable widget (RadioButton,EditText, or CheckBox)?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
You might want to take a look at this issue. Having a focusable item in a row of a
ListView
causes theOnItemClickListener
NOT to be invoked. However, that does not mean you cannot have focusable/clickable items in a row, there are some workarounds like this one.Also, you can take a look at the Call Logs screen. It has a
ListView
with clickable item(the call icon on the right). See Source code hereQuoting comment #31 in the link mentioned by Samuh (which solved the problem for me):
Adding here JIC that webpage is down in the future.
Tried many complex solutions, but this was the simplest one that worked:
Just use
android:focusable="false"
as in:Two best solution
android:descendantFocusability="beforeDescendants"
to listView in xml ORfalse
like
Then it will handle the listView row item child(Button,EditText etc) events instead of listView.setOnItemClick .
If any row item of list contains focusable or clickable view then
OnItemClickListener
won't work.row item must be having param like
android:descendantFocusability="blocksDescendants"
I fixed my problem different , in my item I have more than one LinearLayout so if you give id to your linearayout and setOnclickListener in adapter class it will work, only original effect of touching will dissapear. but this link Making a LinearLayout act like an Button is usefull to make linearlaout act like button on click
item
inside getView method