Skip to content Skip to sidebar Skip to footer

Using Keyboard With Statealwaysvisible, After Touch Any Letter The Showed Alertdialog Opens Selected, Why?

I have only one button in my layout. The activity after count of 10 (five keyboard touchs) shows an AlertDialog. On Manifest the activity has the android:windowSoftInputMode='stat

Solution 1:

This is a View Focus problem. You can solve it with the method below.

Change your code:

AlertDialogalert= builder.create();
  alert.show();

To:

finalAlertDialogalert= builder.create();
    alert.setOnShowListener(newOnShowListener() {

        @OverridepublicvoidonShow(DialogInterface dialog) {
            ViewParentparent= alert.getButton(
                    AlertDialog.BUTTON_POSITIVE).getParent();
            if (parent instanceof ViewGroup) {
                ViewGroupvg= (ViewGroup) parent;
                vg.setFocusable(true);
                vg.setFocusableInTouchMode(true);
                vg.requestFocus();
            }
        }
    });
    alert.show();

Post a Comment for "Using Keyboard With Statealwaysvisible, After Touch Any Letter The Showed Alertdialog Opens Selected, Why?"