0

ユーザーが editText フィールド内で ENTER キーを押したときにメソッドを送信したいと思います。

<EditText android:layout_height="wrap_content"
    android:layout_width="fill_parent" 
    android:imeOptions="actionDone"
    android:singleLine="true" 
 />

Atm これにより、ユーザーが完了を押すと、画面上の次の UI 要素に移動します。しかし、ボタンを偽って送信したいですか?

4

1 に答える 1

1

に を設定する必要がありOnEditorActionListenerますEditText。次に例を示します。

myEditText.setOnEditorActionListener(new OnEditorActionListener() {
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

        if (actionId == EditorInfo.IME_ACTION_DONE) {
            submitButton.performClick();
            return true;
        }

        return false;
    }
});
于 2012-05-17T01:49:00.640 に答える