当前位置: 首页>>代码示例>>Java>>正文


Java Activity.setTheme方法代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:jamesddube,项目名称:LaravelNewsApp,代码行数:19,代码来源:Themes.java

示例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);
}
 
开发者ID:HenriDellal,项目名称:emerald,代码行数:18,代码来源:Themer.java

示例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);
	}
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:11,代码来源:Shake2Share.java

示例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);
    }
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:19,代码来源:ThemeHue.java

示例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));
    }
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:33,代码来源:PluginLibraryInternalProxy.java

示例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;
        }
    }
 
开发者ID:JaeNuguid,项目名称:Kids-Portal-Android,代码行数:39,代码来源:helper_main.java

示例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);
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:30,代码来源:AppInstrumentation.java

示例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;
    }
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:13,代码来源:ThemeUtils.java

示例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);
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:15,代码来源:ChangeModeController.java

示例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...
    }
 
开发者ID:zacharee,项目名称:SystemUITuner2,代码行数:37,代码来源:SetThings.java

示例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);
}
  }
 
开发者ID:vassela,项目名称:AC2RD,代码行数:13,代码来源:ThemeManager.java

示例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);
    }
}
 
开发者ID:kaliturin,项目名称:BlackList,代码行数:8,代码来源:Settings.java

示例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);
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:16,代码来源:ATE.java

示例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);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:Shake2Share.java

示例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);
    }
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:8,代码来源:ThemeUtils.java


注:本文中的android.app.Activity.setTheme方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。