1、EditText 使用中,点击(自动获取焦点)后软键盘无法唤出:
添加
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
或者把继承AlertDialog换为Dialog。
软键盘search型监听:
if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) { //进行搜索操作的方法, String keyword = search.getText().toString().trim(); if (CommonUtils.isAvailable(keyword)) { listener.onSearch(keyword); } // 先隐藏键盘 ((InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(v.getWindowToken(), 0); return true; }