本文整理汇总了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);
}
}