Android——输入法搜索
时间:2019-01-13 14:11:25
收藏:0
阅读:222
Android搜索框输入内容点击键盘的搜索按钮进行搜索
1、在布局XML中的EditView 加入android:imeOptions="actionSearch"
2、监听调用
EditView.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId ==EditorInfo.IME_ACTION_SEARCH){
// 先隐藏键盘
((InputMethodManager) searchText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(
getActivity()
.getCurrentFocus()
.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
//实现自己的搜索逻辑
return true;
}
return false;
}
});原文:https://www.cnblogs.com/xuyj/p/10262403.html
评论(0)