1

This is an item of my ListView:

enter image description here

The star is a Button. I set a OnClickListener for it in getView() method of the Adapter. But I now face a problem - onItemClick doesn't fire after adding the Button. I want a Button to listen for its clicks and the rest part of a view to respond with firing onItemClick. Is there a solution?

user
  • 86,916
  • 18
  • 197
  • 190
bluebyte
  • 560
  • 2
  • 7
  • 23

3 Answers3

1

I am not sure but Button is not working in list item , so plz use ImageView instead of Button. You can also set onClick on ImageView same as Button in your getView() method

ImageView.setOnClickListener().....etc
Niranj Patel
  • 32,980
  • 10
  • 97
  • 133
0

To make the button not focusable (but still clickable):

android:focusable="false"
android:focusableInTouchMode="false"
Barak
  • 16,318
  • 9
  • 52
  • 84
0

If you put onClickListener() on an item in getView() of Adapter , then onItemClickListener() in that Activity doesn't work. For this you can put onClickListener() on your star button and put all other Items in a Layout and put onClickListener() in getView() to that layout.

HTWoks
  • 11
  • 1