commentEditText.requestFocus(); Timer timer = new Timer(); //設置定時器 timer.schedule(new TimerTask() { @Override public void run() { //彈出軟鍵盤的代碼 InputMethodManager imm = (InputMethodManager)mContext.getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(commentEditText, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY); } }, 500);
彈出軟鍵盤以前,要保證EditText獲取到焦點,並延遲執行,等待界面繪製完畢ide