Last Updated: February 25, 2016
·
1.102K
· jimmithy

Before honeycomb, dialogs used their own theme, it is now inherited from the parent

Use this function to generate the AlertDialog context so the theming remains constant.

public Context getThemedContext() {
    Context themedContext;

    if (android.os.Build.VERSION.SDK_INT  >= 
        Build.VERSION_CODES.HONEYCOMB) {
        themedContext = this;
    } else {
        themedContext = new ContextThemeWrapper(this, 
        android.R.style.Theme_Dialog);
    }

    return themedContext;
}