I want to open AlertDialog with EditText element, so that keyboard is show and whole text is selected?
that is wath I try:
public void showRenameDialog(Task task) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Enter the title of Task");
final EditText input = new EditText(this);
input.setId(TEXT_ID);
input.setText(task.getTitle());
input.setSelectAllOnFocus(true);
builder.setView(input);
final Task t = task;
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
...
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
return;
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT);
}
the text is selected, but the keyboard isn't showed.
Ant when I touch the text, keyboard go open, but the text is no more selected.