Reputation: 11975
My ListView's row has one Button. Now i want to set click event to both row and button. But as i know ListView loose its onItemClick property if we set it's child click event. So please guide me a way to doing both at once
Upvotes: 0
Views: 515
Reputation: 5572
If you are using Buttons inside each list item, then set the click listener for the buttons on not on the list item.
Button.setOnClickListener(View.OnClickListener)
The list item clicks should go ignored and the buttons click listeners should do what you want.
Upvotes: 2
Reputation: 241
I don't understand why you don't want to use ListView.setOnItemClickListener(OnItemClickListener) ? Because it react instantly to a touch event. Isn't what you want?
Upvotes: 0
Reputation: 15267
You have to use ListView.setOnItemClickListener(OnItemClickListener)
. See the tutorial.
In OnItemClickListener.onItemClick()
you're provided with the position of the item.
Upvotes: 1