Softkeyboard no se muestra en AlertDialog solo para teléfono
¡Por qué el softkeyboard solo se muestra en la tableta es un misterio!
Aquí está el código que he usado.
AlertDialog.Builder builder = new AlertDialog.Builder(CurrentActivityName.this);
builder.setTitle(“Title”);
builder.setMessage(“Message”);
final EditText input = new EditText(CurrentActivityName.this);
builder.setView(input);
builder.setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//my code
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//my code
}
});
builder.create().show();
Soy capaz de resolverloutilizando postDelayed
con unnúmero de milisegundos para publicar unEjecutable
input.requestFocus();
input.postDelayed(new Runnable() {
@Override
public void run() {
InputMethodManager keyboard = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
keyboard.showSoftInput(input, 0);
}
},200);
Demoras codificadas nunca se recomiendan porque pueden introducircomportamiento impredecible debajodiferentes condiciones / diferentes dispositivos.
Estoy buscando alguna solución estable.