Android examples for Activity:Activity Feature
Overrides whatever theme the activity currently has with either Theme_Holo_Light or Theme_Light, depending on OS support.
/* ActivityHelper.java//from ww w . j av a 2s .co m * See the file "LICENSE.md" for the full license governing this code. */ //package com.java2s; import android.annotation.TargetApi; import android.app.Activity; import android.os.Build; public class Main { /** * Overrides whatever theme the activity currently has with either * Theme_Holo_Light or Theme_Light, depending on OS support. * * @param activity * @param useApplicationTheme */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void setActivityTheme(Activity activity, boolean useApplicationTheme) { if (useApplicationTheme && 0 != activity.getApplicationInfo().theme) { activity.setTheme(activity.getApplicationInfo().theme); } else if (holoSupported()) { activity.setTheme(android.R.style.Theme_Holo_Light); } else { activity.setTheme(android.R.style.Theme_Light); } } public static boolean holoSupported() { return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB; } }