android TextView点击事件,第一次无效,第二次才响应的问题

陈德彪 / 2024-09-20 / 原文

TextView,点击第一次没有反应,点击第二次,出现问题原因是使用了

android:focusableInTouchMode="true"

android:focusableInTouchMode的意思是是否通过touch来获取聚焦,若为true,第一次是获取焦点,第二次才相应click事件,为false,则直接响应。
所以需要将android:focusableInTouchMode设置为false

android:focusableInTouchMode="false"