开发者

Android ListView OnItemClickListener Vs. View OnClickListener

开发者 https://www.devze.com 2022-12-16 14:54 出处:网络
Why does an OnClickListener for a View inside a ListView not respond to a trackball click on the view, while an OnItemClickListener for the ListView does respond to a trackball c开发者_运维知识库lick

Why does an OnClickListener for a View inside a ListView not respond to a trackball click on the view, while an OnItemClickListener for the ListView does respond to a trackball c开发者_运维知识库lick on one of the ListView's views?


That is by design.

The ListView component is specifically built to trigger those events in that way. I believe they are actually defined in AdapterView abstract class. Other AdapterView descendants (Gallery, Spinner, etc.) will also behave the same way.

There is also an ONItemLongClick as well.

View.OnClick is only used by controls with simple semantics, e.g. Button where there is only one "kind" of click.

0

精彩评论

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