鼠标手指 等点击 button switchbutton 等按键 无响应

1、简介

有时候,手指或者 鼠标 点击设备中的某个按键,会出现无响应的情况。

2、原因分析

可能是 组件多层嵌套,按键丢失焦点

3、解决办法

给按键添加 焦点
xml中定义如下:

<Button 
            android:id="@+id/save" 
            android:layout_width="240px" 
            android:layout_height="wrap_content" 
            android:layout_marginTop="300px" 
            android:text="@string/save" 
            android:textSize="23dp" 
            android:focusableInTouchMode="true" /> 

需要添加 android:focusableInTouchMode=“true”,添加后,在点击鼠标时才可以获取焦点。

猜你喜欢

转载自blog.csdn.net/qq_27061049/article/details/86523119
今日推荐