1. 程式人生 > >Dialog中EditText獲取焦點,並且自動彈出軟鍵盤

Dialog中EditText獲取焦點,並且自動彈出軟鍵盤

logs dial tde tco ati delay method post text

       //解決dilaog中EditText無法彈出輸入的問題
        dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
        //彈出對話框後直接彈出鍵盤
        et_newReason.setFocusableInTouchMode(true);
        et_newReason.requestFocus();
        CmzStaffApplication.handler.postDelayed(new Runnable() {
            @Override
            
public void run() { InputMethodManager inputManager =(InputMethodManager) et_newReason.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(et_newReason, 0); } }, 100);

Dialog中EditText獲取焦點,並且自動彈出軟鍵盤