java Force在AlertDialog中显示软键盘
我有以下代码,我认为这些代码可以在显示警报对话框时强制显示键盘
public void showTypeBox(){
edit = new EditText(this);
edit.setPadding(10, 0, 0, 10);
AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle("Type word to search for:")
.setPositiveButton("Search", Main.this)
.setNegativeButton("Cancel", null)
.setView(edit)
.setIcon(R.drawable.menu_icon)
.create();
dialog.show();
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(edit, InputMethodManager.SHOW_IMPLICIT);
}
我看不出我做错了什么
# 1 楼答案
您试图在
EditText
布局并可见之前显示键盘。试试这个: