Tuesday, July 3, 2012

Android - Change the default focus inside a Alert dialogue

set on focus change for any object inside the dialog.

@Override
public void onFocusChange(View view, boolean hasFocus) {
// Set focus where ever you want according to your custom logic

// for example to focus on the positive button after a webview scroll
// web is the webview and the buttons are initialized inside onCreateDialog 

        if(!web.isFocused() && !positiveButton.isFocused() && negativeButton.isFocused()){
            positiveButton.requestFocus();
        }

}


No comments: