Show keyboard automatically

后端 未结 9 2214
悲哀的现实
悲哀的现实 2020-12-08 04:36

Please explain me the issue about soft keyboard. For example, I have an EditText on my activity or dialogfragment or fragmentactivity, whatever. here it is:

         


        
9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 04:51

    I know this has already been answered, but I found a way to do the accepted answer in onCreateDialog instead of just in onCreateView. When you finish with the builder, before you return do the following:

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());  
    // blah blah blah do builder stuff here like setTitle, setView, etc
    
    Dialog d = builder.create();
    

    Here's the important part:

    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
    

提交回复
热议问题