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; }