103

レイアウト XML では、仮想キーボードにどのボタンandroid:imeOptions="actionNext"を追加するかを指定でき、Nextそれをクリックするとフォーカスが次のフィールドにジャンプします。

これをプログラムで行う方法 - たとえば、次のフィールドに移動するためのイベントトリガーフォーカスに基づいていますか?

4

10 に答える 10

210

IME オプションには、EditorInfo クラスの定数を使用できます。お気に入り、

editText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
于 2011-05-09T19:38:24.847 に答える
30

次のフォーカス可能なフィールドを検索してから、 invoke を実行しrequestFocus()ます。

TextView nextField = (TextView)currentField.focusSearch(View.FOCUS_RIGHT);
nextField.requestFocus();
于 2010-08-11T14:13:18.793 に答える
23

使用している場合は、単なる提案

     EditTextSample.setImeOptions(EditorInfo.IME_ACTION_DONE); 

機能しません。EditText が 1 行を使用していることを確認してください。

例えば:

       editTextSample.setSingleLine();
于 2016-02-01T02:20:58.840 に答える
7

QWERTY仮想キーボードで使用可能なデフォルトのキーとは別に、追加のキーを追加する必要が常にあります。

XML の使用

<EditText android:text="@+id/EditText01" 
android:id="@+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:imeOptions="actionDone"/>

By Programmatic Way

は、 AndroidEditorInfoアプリケーションであらゆるタイプのユーザー入力を処理する必要がある場合に最も便利なクラスです。

IME_ACTION_DONE:このアクションは、何も入力しない場合に「完了」操作を実行し、IME は閉じられます。

 EditTextSample.setImeOptions(EditorInfo.IME_ACTION_DONE);

詳細については、 http://developer.android.com/reference/android/view/inputmethod/EditorInfo.htmlをご覧ください。

于 2015-05-03T06:30:21.243 に答える
1

コトリンのペンダント

editText.imeOptions = EditorInfo.IME_ACTION_DONE
于 2018-10-22T14:01:55.920 に答える
0

次のコードを使用して、次のフィールドにジャンプできます。

BaseInputConnection inputConnection = new BaseInputConnection(editText, true);
inputConnection.performEditorAction(EditorInfo.IME_ACTION_NEXT);
//Use EditorInfo.IME_ACTION_UNSPECIFIED if you set android:imeOptions on the EditText
于 2021-01-15T20:33:24.627 に答える
0

あなたはこれを行うことができます

edittext.imeOptions = EditorInfo.IME_ACTION_DONE //for done button

また

edittext.imeOptions = EditorInfo.IME_ACTION_NEXT //for next button

しかし... 編集テキストにフィルターを使用している場合は、設定する必要があることを理解する必要があります

edittext.setSingleLine()
于 2020-08-20T08:04:07.667 に答える