Solve the problem that the EditText cannot pop up the soft keyboard in the Android custom Dialog
Problem code
AlertDialog.Builder builder = new AlertDialog.Builder(this);
final Dialog dialog = builder.create();
builder.setView(View.inflate(this, R.layout.creat_new_function, null));
dialog.show();
Window window = dialog.getWindow();
window.setContentView(R.layout.creat_new_function);
Debug interface
Modify the code
final Dialog dialog = new Dialog(this);
dialog.setContentView(View.inflate(this, R.layout.creat_new_function, null));
dialog.show();
Window window = dialog.getWindow();
window.setContentView(R.layout.creat_new_function);
Recommission
Solution
Due to the limitations of AlertDialog itself, the focus cannot be obtained, so replace AlertDialog in the code with Dialog to solve it.