【问题标题】:How to display "search" as text instead of Serach icon on android soft keyboard如何在android软键盘上将“搜索”显示为文本而不是搜索图标
【发布时间】:2015-08-06 06:24:56
【问题描述】:

如何用软键盘上的“搜索”文本替换搜索图标。

<EditText 
android:imeOptions="actionSearch" />

【问题讨论】:

  • 至少在某些操作系统版本上,imeOptions 仅在设置了 inputType 时才有效。

标签: android android-activity android-softkeyboard


【解决方案1】:

不要使用 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; 
} }); 

【讨论】:

    【解决方案2】:

    答案取自thisstackoverflow 问题。

    尝试设置

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

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

    【讨论】:

    • 看看这个link 寻找可能的解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-10
    • 2016-05-04
    相关资源
    最近更新 更多