2

私は android:imeOptions="actionSearch" を使用しています

editTextで私の質問は、ユーザーがソフトキーボードの検索ボタンを押した場合、自分のイベントを書くことができますか?

実際には、Androidアクティビティで使用するボタンと同様のソフトキーボード検索ボタンの機能を実行したいと考えています。

どんな助けでも感謝します。

4

2 に答える 2

6

This is what I ended up using:

EditText SearchEditText = (EditText) findViewById(R.id.txtMapSearch);
SearchEditText.setOnEditorActionListener(new OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) {
        // TODO Auto-generated method stub
        if (arg1 == EditorInfo.IME_ACTION_SEARCH) {
            // search pressed and perform your functionality.
        }
        return false;
    }
});
于 2010-04-07T12:36:22.027 に答える
5

を呼び出しsetOnEditorActionListener()て、ユーザーがソフト キーボードのアクション ボタンをタップしたときに呼び出されるEditTextを登録します。TextView.OnEditorActionListener

于 2010-04-07T11:10:42.343 に答える