本文整理匯總了Java中android.app.Activity.setTheme方法的典型用法代碼示例。如果您正苦於以下問題:Java Activity.setTheme方法的具體用法?Java Activity.setTheme怎麽用?Java Activity.setTheme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.Activity
的用法示例。
在下文中一共展示了Activity.setTheme方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: applyTheme
import android.app.Activity; //導入方法依賴的package包/類
public static void applyTheme(Activity activity){
String theme = PreferenceManager.getDefaultSharedPreferences(activity.getApplicationContext())
.getString("pref_theme", "light");
switch (theme){
case "light":{
activity.setTheme(R.style.AppTheme_NoActionBar);
break;
}
case "dark":{
activity.setTheme(R.style.AppTheme_Dark_NoActionBar);
break;
}
default:{
activity.setTheme(R.style.AppTheme_NoActionBar);
break;
}
}
}
示例2: applyTheme
import android.app.Activity; //導入方法依賴的package包/類
public static void applyTheme(Activity activity, SharedPreferences options) {
switch (theme) {
case LIGHT:
activity.setTheme(R.style.AppTheme_Light);
break;
case DARK:
activity.setTheme(R.style.AppTheme_Dark);
break;
case WALLPAPER_LIGHT:
activity.setTheme(R.style.AppTheme_Light_Wallpaper);
break;
case WALLPAPER_DARK:
activity.setTheme(R.style.AppTheme_Dark_Wallpaper);
break;
}
setBarTheme(activity, theme);
}
示例3: setActivity
import android.app.Activity; //導入方法依賴的package包/類
public void setActivity(Activity activity) {
super.setActivity(activity);
int resId = getBitmapRes(activity, "ssdk_oks_shake_to_share_back");
if (resId > 0) {
activity.setTheme(android.R.style.Theme_Dialog);
activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
Window win = activity.getWindow();
win.setBackgroundDrawableResource(resId);
}
}
示例4: setTheme
import android.app.Activity; //導入方法依賴的package包/類
public static void setTheme(Activity activity)
{
//Grab an instance of SharedPrefs if we haven't already
if (mSharedPreferences == null)
{
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
}
//Grab the value of the darkTheme preference
boolean desiredThemeIsDark = mSharedPreferences.getBoolean("darkTheme", false);
//We only need to explicitly set the theme if the user wants the dark theme, as light is the default
if (desiredThemeIsDark)
{
//NB: this *must* be called before setContentView(), else weird things happen
activity.setTheme(R.style.DarkTheme);
}
}
示例5: handleActivityCreateBefore
import android.app.Activity; //導入方法依賴的package包/類
/**
* @hide 內部方法,插件框架使用
* 插件的Activity的onCreate調用前調用此方法
* @param activity
* @param savedInstanceState
*/
public void handleActivityCreateBefore(Activity activity, Bundle savedInstanceState) {
if (LOG) {
LogDebug.d(PLUGIN_TAG, "activity create before: " + activity.getClass().getName() + " this=" + activity.hashCode() + " taskid=" + activity.getTaskId());
}
// 對FragmentActivity做特殊處理
if (savedInstanceState != null) {
//
savedInstanceState.setClassLoader(activity.getClassLoader());
//
try {
savedInstanceState.remove("android:support:fragments");
} catch (Throwable e) {
if (LOGR) {
LogRelease.e(PLUGIN_TAG, "a.c.b1: " + e.getMessage(), e);
}
}
}
// 對FragmentActivity做特殊處理
Intent intent = activity.getIntent();
if (intent != null) {
intent.setExtrasClassLoader(activity.getClassLoader());
activity.setTheme(getThemeId(activity, intent));
}
}
示例6: setTheme
import android.app.Activity; //導入方法依賴的package包/類
public static void setTheme (Activity activity) {
sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
String theme = sharedPref.getString("theme", "0");
switch (theme) {
case "0":
activity.setTheme(R.style.AppTheme_blue);
break;
case "1":
activity.setTheme(R.style.AppTheme);
break;
case "2":
activity.setTheme(R.style.AppTheme_pink);
break;
case "3":
activity.setTheme(R.style.AppTheme_purple);
break;
case "4":
activity.setTheme(R.style.AppTheme_teal);
break;
case "5":
activity.setTheme(R.style.AppTheme_red);
break;
case "6":
activity.setTheme(R.style.AppTheme_orange);
break;
case "7":
activity.setTheme(R.style.AppTheme_brown);
break;
case "8":
activity.setTheme(R.style.AppTheme_grey);
break;
case "9":
activity.setTheme(R.style.AppTheme_darkGrey);
break;
}
}
示例7: callActivityOnCreate
import android.app.Activity; //導入方法依賴的package包/類
@Override
public void callActivityOnCreate(Activity activity, Bundle icicle) {
if (icicle != null) {
BundleCompat.clearParcelledData(icicle);
}
VirtualCore.get().getComponentDelegate().beforeActivityCreate(activity);
IBinder token = mirror.android.app.Activity.mToken.get(activity);
ActivityClientRecord r = VActivityManager.get().getActivityRecord(token);
if (r != null) {
r.activity = activity;
}
ContextFixer.fixContext(activity);
ActivityFixer.fixActivity(activity);
ActivityInfo info = null;
if (r != null) {
info = r.info;
}
if (info != null) {
if (info.theme != 0) {
activity.setTheme(info.theme);
}
if (activity.getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
&& info.screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
activity.setRequestedOrientation(info.screenOrientation);
}
}
super.callActivityOnCreate(activity, icicle);
VirtualCore.get().getComponentDelegate().afterActivityCreate(activity);
}
示例8: setCurrentTheme
import android.app.Activity; //導入方法依賴的package包/類
public static void setCurrentTheme(final Activity activity) {
switch (ThemeUtils.getCurrentTheme(activity)) {
case ThemeUtils.THEME_MATERIAL_DARK:
activity.setTheme(R.style.AppThemeDark);
break;
case ThemeUtils.THEME_MATERIAL_MONOCHROME:
activity.setTheme(R.style.AppThemeMonochrome);
break;
default:
break;
}
}
示例9: changeDay
import android.app.Activity; //導入方法依賴的package包/類
/**
*
* @param ctx 上下文
* @param style 切換style
*/
public static void changeDay(Activity ctx,int style) {
if(mBackGroundDrawableViews == null || mOneTextColorViews == null || mTwoTextColorViews == null ||mThreeTextColorViews == null ||mBackGroundViews == null){
throw new RuntimeException("請先調用init()初始化方法!");
}
ChangeModeHelper.setChangeMode(ctx, ChangeModeHelper.MODE_DAY);
ctx.setTheme(style);
showAnimation(ctx);
refreshUI(ctx);
}
示例10: SetThings
import android.app.Activity; //導入方法依賴的package包/類
public SetThings(Activity activity) {
//set all variables
sharedPreferences = activity.getSharedPreferences(activity.getResources().getText(R.string.sharedprefs_id).toString(), Context.MODE_PRIVATE);
editor = sharedPreferences.edit();
editor.apply();
Dark = sharedPreferences.getBoolean("isDark", false);
setup = sharedPreferences.getBoolean("isSetup", false);
exceptions = new Exceptions();
SDK_INT = Build.VERSION.SDK_INT;
//noinspection deprecation
titleText = activity.getResources().getColor(Dark ? android.R.color.primary_text_dark : android.R.color.primary_text_light);
//noinspection deprecation,deprecation
drawerItem = Dark ? activity.getResources().getColorStateList(R.color.drawer_item_dark) : activity.getResources().getColorStateList(R.color.drawer_item_light);
// activity.setTheme(SetupActivity.class == activity.getClass() || NoRootSystemSettingsActivity.class == activity.getClass() ? Dark ? R.style.DARK : R.style.AppTheme : Dark ? R.style.DARK_NoAppBar : R.style.AppTheme_NoActionBar);
activity.setTheme(Dark ? R.style.DARK : R.style.AppTheme);
style = Dark ? R.style.DARK_NoAppBar : R.style.AppTheme_NoActionBar; //is dark mode on?
pages = new ArrayList<Integer>() {{ //all (currently used) fragments
add(R.id.nav_home);
add(R.id.nav_statusbar);
add(R.id.nav_demo_mode);
add(R.id.nav_about);
add(R.id.nav_settings);
add(R.id.nav_misc);
add(R.id.nav_quick_settings);
add(R.id.nav_touchwiz);
}};
currentActivity = activity;
context = currentActivity; //kinda pointless...
}
示例11: setTheme
import android.app.Activity; //導入方法依賴的package包/類
public void setTheme(Context context, Activity activity, int theme)
{
try
{
activity.setTheme(theme);
}
catch (Exception e)
{
Log.w("ThemeManager", "setTheme : " + context.getString(R.string.log_theme_manager_error_set_theme) + " : " + theme + " : " + e);
databaseManager.insertLog(context, "" + context.getString(R.string.log_theme_manager_error_set_theme) + " : " + theme, new Date().getTime(), 2, false);
}
}
示例12: applyCurrentTheme
import android.app.Activity; //導入方法依賴的package包/類
public static void applyCurrentTheme(Activity activity) {
if (getBooleanValue(activity, Settings.UI_THEME_DARK)) {
activity.setTheme(R.style.AppTheme_Dark);
} else {
activity.setTheme(R.style.AppTheme_Light);
}
}
示例13: preApply
import android.app.Activity; //導入方法依賴的package包/類
public static void preApply(@NonNull Activity activity, @Nullable String key) {
didPreApply = activity.getClass();
synchronized (IGNORE_TAG) {
if (mPostInflationApply != null) {
mPostInflationApply.clear();
mPostInflationApply = null;
}
}
int activityTheme = activity instanceof ATEActivityThemeCustomizer ?
((ATEActivityThemeCustomizer) activity).getActivityTheme() : Config.activityTheme(activity, key);
if (activityTheme != 0) activity.setTheme(activityTheme);
final LayoutInflater li = activity.getLayoutInflater();
ATEUtil.setInflaterFactory(li, activity);
}
示例14: setActivity
import android.app.Activity; //導入方法依賴的package包/類
public void setActivity(Activity activity) {
super.setActivity(activity);
int resId = R.getBitmapRes(activity, "ssdk_oks_shake_to_share_back");
if (resId > 0) {
activity.setTheme(16973835);
activity.requestWindowFeature(1);
activity.getWindow().setBackgroundDrawableResource(resId);
}
}
示例15: applyTheme
import android.app.Activity; //導入方法依賴的package包/類
public static void applyTheme(Activity activity) {
int themeId = getThemeId(activity);
activity.setTheme(themeId);
if (isWallpaperTheme(themeId)) {
applyWallpaperDim(activity);
}
}