android软键盘的搜索按钮
如图所示:
一.如何设置软键盘显示搜索按钮?
在XML在输入框中加入android:imeOptions="actionSearch"
二.如何监听搜索按钮?
et_key.setOnEditorActionListener(newTextView.OnEditorActionListener() {
@Override
public booleanonEditorAction(TextView v, intactionId,KeyEvent event) {
if(actionId == EditorInfo.IME_ACTION_SEARCH){
// 先隐藏键盘
((InputMethodManager)et_key.getContext().getSystemService(Context.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(
SearchActivity.this
.getCurrentFocus()
.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
String keyWord =et_key.getText().toString().trim();
searchByKeyWord(keyWord);
return true;
}
return false;
}
});
三.如何解决软键盘会把原界面挤上去的问题?
在androidMainfest.xml文件中在此Activity中写入 android:windowSoftInputMode="adjustPan"
更多相关文章
- android 自定义软键盘
- Android AlertDialog包含EditText,软键盘不能弹出的解决方法
- Android PopUpWindow 软键盘
- android 单选(RadioGroup )复选(CheckBox)按钮的应用
- Android屏蔽EditText软键盘的方法
- Android 标题栏添加返回按钮及响应
- android键盘映射之三