更新时间:2023-12-04 09:56:16
与大多数其他控件不同,EditText
在系统处于触摸模式"时是可聚焦的.第一个单击事件聚焦控件,而第二个单击事件实际上触发 OnClickListener
.如果您使用 android:focusableInTouchMode
View 属性禁用触摸模式焦点,则 OnClickListener
应该会按预期触发.
Unlike most other controls, EditText
s are focusable while the system is in 'touch mode'. The first click event focuses the control, while the second click event actually fires the OnClickListener
. If you disable touch-mode focus with the android:focusableInTouchMode
View attribute, the OnClickListener
should fire as expected.
<EditText
android:text="@+id/EditText01"
android:id="@+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusableInTouchMode="false" />