當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。