set Theme to Context - Android android.content

Android examples for android.content:Context

Description

set Theme to Context

Demo Code


//package com.java2s;
import android.content.Context;
import android.os.Build;

public class Main {
    public static void setTheme(boolean dialog, Context context) {
        int theme = android.R.style.Theme_Black;
        if (Build.VERSION.SDK_INT >= 11) {
            theme = 0x0103006b; //-> android.R.Theme_Holo, needed, because build target is only 2.3.1
            if (dialog)
                theme = 0x0103006f; //-> android.R.Theme_Holo_Dialog, needed, because build target is only 2.3.1
        } else {//  www  . j  a  v a2s .co  m
            if (dialog) {
                theme = android.R.style.Theme_Dialog;
            }
        }
        context.setTheme(theme);
    }
}

Related Tutorials