when using AlertDialog.Builder with EditText, the Soft Keyboard doesn't pop

前端 未结 12 1332
一生所求
一生所求 2020-11-30 23:13

I am using AlertDialog.Builder in order to create an input box, with EditText as the input method.

Unfortunately, the Soft Keyboard doesn\'t pop, al

12条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 23:59

    Try this, its working for me

    If you want to display soft keyboard:

    InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                        imm.showSoftInput(input.getWindowToken(), 0);
    

    And if you want to hide the it:

      InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
    

提交回复
热议问题