开发者

Clicking List-view row and child Button as well

开发者 https://www.devze.com 2023-03-02 10:36 出处:网络
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 s开发者_运维知识库et it\'s child click event. So pl

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 s开发者_运维知识库et it's child click event. So please guide me a way to doing both at once


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.


You have to use ListView.setOnItemClickListener(OnItemClickListener). See the tutorial.

In OnItemClickListener.onItemClick() you're provided with the position of the item.


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消