【Android】TextView需要连续点击两次才会触发onClick

为什么TextView有时候需要点击两次才会触发onClick

原因

  • 因为TextView设置了focusableInTouchMode="true",所以onClick需要连续点击两次才会触发。

方案

  1. focusableInTouchMode还是设置为true,然后将setOnClickListener改成setOnTouchListener
  2. 删除focusableInTouchMode,或者将focusableInTouchMode设置为false

猜你喜欢

转载自blog.csdn.net/weixin_44500303/article/details/128639243