Why does EdiText in Android Dialog not automatically pop up the input method?

Under normal circumstances, most of the default EditText will automatically wake up the input method, but some people in the group asked why the EditText in the Dialog can't do this. After a rough analysis of the following, Dialog is its own separate Window. The behavior after setContentView in it may be different from that of Activity's window, or it may be due to the life cycle. As a result, although the EditText of Dialog does request a wake-up input method, the input method does not Display correctly. Let's not continue to analyze for the time being. Since it is due to the problem of requesting the display of the input method, we can just request an input at the right time. Directly on the code, this is just an idea, how to organize the code, and the individual can play freely.

` Dialog dialog = new Dialog(this); final EditText view = new EditText(this); dialog.setContentView(view); dialog.show(); // view.post(new Runnable() {

		@Override
		public void run() {
			InputMethodManager im = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
			im.showSoftInput(view, 0);
		}
	});`
{{o.name}}
{{m.name}}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324155433&siteId=291194637