1.第一种方式,代码设置,注意先后顺序:
btn.setFocusable(true);
btn.setFocusableInTouchMode(true);
btn.requestFocus();
btn.requestFocusFromTouch();
2.第二种方式,xml配置:
android:focusable="true"
android:focusableInTouchMode="true"
1.第一种方式,代码设置,注意先后顺序:
btn.setFocusable(true);
btn.setFocusableInTouchMode(true);
btn.requestFocus();
btn.requestFocusFromTouch();
2.第二种方式,xml配置:
android:focusable="true"
android:focusableInTouchMode="true"