How To Set Focus To Android Alert Dialog Negative Button?
I have written code to setFocus to ALert Dialog negative button by using requestFocus(). But the button color will not change.I can able to set background image to that button manu
Solution 1:
Just setOnShowListener() to AlertDialog, and set focus on the negative button.
alertDialog.setOnShowListener(new DialogInterface.OnShowListener(){
@Override
public void onShow(DialogInterface dialog) {
Button negative = alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
negative.setFocusable(true);
negative.setFocusableInTouchMode(true);
negative.requestFocus();
}
});
alertDialog.show();
Post a Comment for "How To Set Focus To Android Alert Dialog Negative Button?"