如何在 android 软键盘上将 "search" 显示为文本而不是搜索图标

How to display "search" as text instead of Serach icon on android soft keyboard

如何在软键盘上用文本 "Search" 替换搜索图标。

<EditText 
android:imeOptions="actionSearch" />

不使用 imeOptions,而是使用以下 :-

<EditText android:imeOptions="actionSearch" 
         android:inputType="text"/>

要处理点击侦听器,请执行以下操作:

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; 
} }); 

答案取自 this Whosebug 问题。

尝试设置

  • android:imeActionLabel 在 XML 或
  • 在 java 代码中 .setImeActionLabel()

editText.setImeActionLabel(getString(R.string.xxx), EditorInfo.IME_ACTION_SEARCH);