1

私はこれを機能させようとしています: EditText の XML には次のものがあります:

    android:imeActionLabel="Search"
    android:imeOptions="actionSearch"

しかし、うまくいきません。コード内

    search.setImeOptions(EditorInfo.IME_ACTION_SEARCH);

どちらも機能しません。手がかりはありますか?

4

1 に答える 1

1

これを試して

あなたのxmlファイルで

<EditText
            android:id="@+id/rechercheTextView"
            android:layout_width="174dp"
            android:layout_height="wrap_content"
            android:background="@android:color/transparent"
            android:imeOptions="actionSearch"
            android:inputType="text"
             />

あなたのアクティビティで

EditText rechTxt = (EditText) findViewById(R.id.rechercheTextView);
rechTxt.setOnEditorActionListener(new OnEditorActionListener() {

    public boolean onEditorAction(TextView v, int actionId,
                        KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_SEARCH) {

        Toast.makeText(getApplicationContext(),"search",Toast.LENGTH_LONG).show();
        return true;
                    }
                    return false;
                }
            });
于 2012-08-23T10:41:51.520 に答える