3

我想更改输入按钮的名称(图中圈出的按钮)来搜索

在此处输入图像描述

所以我用

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


                android:id="@+id/et_PatientID"

                android:layout_width="400dip"
                android:layout_height="50dip"
                android:layout_toRightOf="@id/tv_patientID"
                android:background="@android:drawable/editbox_background" />

但它没有用

4

1 回答 1

5

添加android:imeOptions="actionSearch"android:inputType="text"到您的 EditText 视图

还添加编辑器动作监听器

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_SEARCH) {
            performSearch();
            return true;
        }
        return false;
    }
});

<EditText 
            android:id="@+id/et_PatientID"
            android:inputType="text"
            android:layout_width="400dip"
            android:layout_height="50dip"
            android:layout_toRightOf="@id/tv_patientID"
            android:background="@android:drawable/editbox_background"
            android:imeOptions="actionSearch" 
            android:imeActionLabel="Search"  />
于 2012-07-01T07:47:26.580 回答