0
アンドロイドキーパッドの矢印(次のキー)を押した後、フォーカスされたボタンが異なる色で強調表示されるようにするにはどうすればよいですか?キーボードを使用してフォーカスのあるボタンの色を変更しますか?
アンドロイドキーパッドの矢印(次のキー)を押した後、フォーカスされたボタンが異なる色で強調表示されるようにするにはどうすればよいですか?キーボードを使用してフォーカスのあるボタンの色を変更しますか?
ボタンの色の変化につながる次のボタンについては、ここで解決しています。
チェックボタンとeditext属性。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/frameContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="16dp"
tools:context="com.android.buffer.exampleapplication.MainActivity">
<EditText
android:id="@+id/etFocus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="enter name"
android:maxLines="1"
android:imeOptions="actionNext"
android:singleLine="true"/>
<Button
android:id="@+id/btn"
android:focusableInTouchMode="true"
android:focusable="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button"/>
</LinearLayout>
ここでは動作させるコードです。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button button = findViewById(R.id.btn);
final EditText editText = findViewById(R.id.etFocus);
editText.setNextFocusDownId(R.id.btn);
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(final TextView textView, final int i, final KeyEvent keyEvent) {
if (i== EditorInfo.IME_ACTION_NEXT){
editText.clearFocus();
button.requestFocus();
}
return false;
}
});
button.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(final View view, final boolean b) {
if (view.isFocused()){
button.setBackgroundResource(R.color.colorAccent);
}
}
});
}
https://developer.android.com/training/keyboard-input/navigation.html –
@SouravBagchiビッグTHX !!!! – iFr0z