我在应用程序中看到很多搜索框,如果单击键盘布局就会变成搜索按钮。如果单击 EditText,如何将 Android 键盘布局从 Enter 更改为 Search?就像其他搜索框一样。谢谢
最佳答案
添加
android:imeOptions="actionSearch"
到布局文件中的 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;
}
});
关于安卓键盘布局搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38148380/