Para todos,NumberPicker en AlertDialog siempre activa el teclado. ¿Cómo deshabilitar esto?
Estoy tratando de hacer que un simple NumberPicker funcione en un AlertDialog. El problema es que cada vez que aumento/disminuyo el valor en el selector de números, el teclado se activa.
Hay muchas publicaciones que describen este problema, pero ninguna de las sugerencias funciona. que he intentado:
android:configChanges="keyboard|keyboardHidden"
Y
inputManager.hideSoftInputFromWindow(currentView.getWindowToken(), 0);
Y
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
me han tratado de llamar a estas funciones antes y después de la inicialización (dialog.show()), en eventos de pulsación (usando oyentes obviamente), etc. pero hasta ahora no hay suerte.
El código completo:
popup.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<NumberPicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/myNumber"
android:configChanges="keyboard|keyboardHidden"
/>
</RelativeLayout>
Y la función de llamada:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
} });
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
} });
View view = getLayoutInflater().inflate(R.layout.popup, null);
builder.setView (view);
final AlertDialog dialog = builder.create();
NumberPicker picker = (NumberPicker) view.findViewById(R.id.myNumber);
picker.setMinValue(0);
picker.setMaxValue(999);
dialog.getWindow().
setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
dialog.show();
Cualquier ayuda apreciado
Barry
También puedes configurar esto en XML: android: descenddantFocusability = "blocksDescendants" – Borzh