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


Java Resources.updateConfiguration方法代码示例

本文整理汇总了Java中android.content.res.Resources.updateConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java Resources.updateConfiguration方法的具体用法?Java Resources.updateConfiguration怎么用?Java Resources.updateConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.res.Resources的用法示例。


在下文中一共展示了Resources.updateConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkLanguage

import android.content.res.Resources; //导入方法依赖的package包/类
private void checkLanguage() {

        SharedPreferences sharedPreferences = this.getSharedPreferences("set", MODE_PRIVATE);
        /**
         * 获取系统配置
         */
        Resources resources = getResources();
        DisplayMetrics dm = resources.getDisplayMetrics();
        Configuration config = resources.getConfiguration();


        if (LANGUAGE_CN.equals(sharedPreferences.getString("language", "0"))) {

            config.locale = Locale.SIMPLIFIED_CHINESE;
            resources.updateConfiguration(config, dm);
        } else if (LANGUAGE_EN.equals(sharedPreferences.getString("language", "0"))) {

            config.locale = Locale.ENGLISH;
            resources.updateConfiguration(config, dm);
        } else {

            config.locale = Locale.SIMPLIFIED_CHINESE;
            resources.updateConfiguration(config, dm);
        }

    }
 
开发者ID:stewForAni,项目名称:Lamp,代码行数:27,代码来源:WifiConnectActivity.java

示例2: onCreate

import android.content.res.Resources; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    Resources resources = getResources();
    DisplayMetrics dm = resources.getDisplayMetrics();
    Configuration config = resources.getConfiguration();
    // 应用用户选择语言
    String language = SPUtil.getInstance(this).getLanguage();
    if ("".equals(language)){
        language =Locale.getDefault().getLanguage();
    }
    if (language.equals(SPUtil.LANGUAGE_CHINESE)) {
        config.setLocale(Locale.getDefault());
    } else  {
        config.setLocale(Locale.ENGLISH);
    }
    resources.updateConfiguration(config, dm);

    mContext=getApplicationContext();
}
 
开发者ID:EggUncle,项目名称:XposedNavigationBar,代码行数:21,代码来源:MyApplication.java

示例3: changeLanguage

import android.content.res.Resources; //导入方法依赖的package包/类
public static void changeLanguage(Context context) {
    Resources resources = context.getResources();
    DisplayMetrics dm = resources.getDisplayMetrics();
    Configuration config = resources.getConfiguration();
    switch (SharedPreManager.getInstance().getLanguage(context)) {
        case Constant.LANGUAGE_CHINA:
            config.locale = Locale.SIMPLIFIED_CHINESE;
            break;
        case Constant.LANGUAGE_ENGLISH:
            config.locale = Locale.ENGLISH;
            break;
        case Constant.LANGUAGE_DEFAULT:
            config.locale = Locale.getDefault();
            break;
    }
    // 应用用户选择语言
    resources.updateConfiguration(config, dm);
}
 
开发者ID:Yuanhongliang,项目名称:HLOLI,代码行数:19,代码来源:App.java

示例4: hasDictionary

import android.content.res.Resources; //导入方法依赖的package包/类
private boolean hasDictionary(Locale locale, Context ctx) {
    Resources res = getResources();
    Configuration conf = res.getConfiguration();
    Locale saveLocale = conf.locale;
    boolean haveDictionary = false;
    conf.locale = locale;
    res.updateConfiguration(conf, res.getDisplayMetrics());

    //somewhat a hack. But simply querying the dictionary will always return an English
    //dictionary in KP2A so if we get a dict, we wouldn't know if it's language specific 
    if (locale.getLanguage().equals("en"))
    {
    	haveDictionary = true;
    }
    else 
    {
        BinaryDictionary plug = PluginManager.getDictionary(getApplicationContext(), locale.getLanguage());
        if (plug != null) {
        	plug.close();
        	haveDictionary = true;
        }
    }
    conf.locale = saveLocale;
    res.updateConfiguration(conf, res.getDisplayMetrics());
    return haveDictionary;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:27,代码来源:InputLanguageSelection.java

示例5: runInLocale

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Execute {@link #job(Resources)} method in specified system locale exclusively.
 *
 * @param res the resources to use.
 * @param newLocale the locale to change to. Run in system locale if null.
 * @return the value returned from {@link #job(Resources)}.
 */
public T runInLocale(final Resources res, final Locale newLocale) {
    synchronized (sLockForRunInLocale) {
        final Configuration conf = res.getConfiguration();
        if (newLocale == null || newLocale.equals(conf.locale)) {
            return job(res);
        }
        final Locale savedLocale = conf.locale;
        try {
            conf.locale = newLocale;
            res.updateConfiguration(conf, null);
            return job(res);
        } finally {
            conf.locale = savedLocale;
            res.updateConfiguration(conf, null);
        }
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:25,代码来源:RunInLocale.java

示例6: changeLocale

import android.content.res.Resources; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public static void changeLocale(String locale) {
    Context context = InstrumentationRegistry.getInstrumentation()
            .getTargetContext();

    Resources res = context.getApplicationContext().getResources();
    Configuration config = res.getConfiguration();


    config.setLocale(new Locale(locale));
    if (SDK_INT >= 25) {
        context.createConfigurationContext(config);
    } else {
        res.updateConfiguration(config, res.getDisplayMetrics());
    }
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:17,代码来源:SwitchLocaleTest.java

示例7: updateConfigurationForNightMode

import android.content.res.Resources; //导入方法依赖的package包/类
private boolean updateConfigurationForNightMode(int mode) {
    Resources res = this.mContext.getResources();
    Configuration conf = res.getConfiguration();
    int currentNightMode = conf.uiMode & 48;
    int newNightMode = 0;
    switch (mode) {
        case 1:
            newNightMode = 16;
            break;
        case 2:
            newNightMode = 32;
            break;
    }
    if (currentNightMode == newNightMode) {
        return false;
    }
    conf.uiMode = (conf.uiMode & -49) | newNightMode;
    res.updateConfiguration(conf, null);
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:AppCompatDelegateImplV14.java

示例8: initTextSize

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * 使其系统更改字体大小无效
 */
private void initTextSize() {
    Resources res = getResources();
    Configuration config = new Configuration();
    config.setToDefaults();
    res.updateConfiguration(config, res.getDisplayMetrics());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:CloudReaderApplication.java

示例9: setLocale

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Set the app to use the given locale. Useful for testing translations. This is normally
 * not needed because the device locale is applied automatically.
 * @param context - context from which to get resources
 * @param locale - the locale to use
 */
public static void setLocale(@NonNull Context context, @NonNull Locale locale) {
    Locale.setDefault(locale);
    Resources res = context.getResources();
    DisplayMetrics dm = res.getDisplayMetrics();
    android.content.res.Configuration conf = res.getConfiguration();
    conf.locale = Locale.getDefault();
    res.updateConfiguration(conf, dm);
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:15,代码来源:AppUtils.java

示例10: getResources

import android.content.res.Resources; //导入方法依赖的package包/类
@Override
public Resources getResources() {
    //保持字体不变
    Resources res = super.getResources();
    Configuration config = new Configuration();
    config.setToDefaults();
    res.updateConfiguration(config, res.getDisplayMetrics());
    return res;
}
 
开发者ID:YunzhanghuOpen,项目名称:redpacketui-open,代码行数:10,代码来源:RPBaseActivity.java

示例11: updateConfiguration

import android.content.res.Resources; //导入方法依赖的package包/类
private void updateConfiguration() {
    if (JarApplication.getInstance() != null && JarApplication.getInstance().getResources() != null) {
        Resources superRes = JarApplication.getInstance().getResources();
        Configuration configuration = superRes.getConfiguration();
        DisplayMetrics displayMetrics = superRes.getDisplayMetrics();
        JarResources jarResources = getOverrideResources();
        if (jarResources != null) {
            Resources resources = jarResources.getResources();
            if (resources != null && configuration != null && displayMetrics != null) {
                resources.updateConfiguration(configuration, displayMetrics);
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:15,代码来源:ProxyFragment.java

示例12: applyLanguageForContext

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Setting {@link Locale} for {@link Context}.
 */
@NonNull
public static Context applyLanguageForContext(@NonNull Context context, @NonNull Locale locale) {
    Resources resources = context.getResources();
    Configuration config = resources.getConfiguration();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        config.setLocale(locale);
        return context.createConfigurationContext(config);
    } else {
        config.locale = locale;
        resources.updateConfiguration(config, resources.getDisplayMetrics());
        return context;
    }
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:17,代码来源:AlbumUtils.java

示例13: setLocale

import android.content.res.Resources; //导入方法依赖的package包/类
public  void setLocale(String lang) {
    Locale myLocale = new Locale(lang);
    Resources res = getResources();
    DisplayMetrics dm = res.getDisplayMetrics();
    Configuration conf = res.getConfiguration();
    conf.locale = myLocale;
    res.updateConfiguration(conf, dm);
    Intent refresh = new Intent(getContext(), MainActivity.class);
    startActivity(refresh);
    getActivity().finish();
}
 
开发者ID:jcolladosp,项目名称:PimPam,代码行数:12,代码来源:SettingsFragment.java

示例14: getResources

import android.content.res.Resources; //导入方法依赖的package包/类
@Override
public Resources getResources() {
    Resources res = super.getResources();
    if (res.getConfiguration().fontScale != 1) {//非默认值
        Configuration newConfig = new Configuration();
        newConfig.setToDefaults();//设置默认
        res.updateConfiguration(newConfig, res.getDisplayMetrics());
    }
    return res;
}
 
开发者ID:quickhybrid,项目名称:quickhybrid-android,代码行数:11,代码来源:FrmApplication.java

示例15: changeLanguage

import android.content.res.Resources; //导入方法依赖的package包/类
/**
 * Нөөц дэх хэлний файлууд уншиж текстүүд орчуулах
 *
 * @param lang res/values/strings xml файлаас ямар хэл сонгохыг заана
 */
private void changeLanguage(String lang) {
    Resources res = getApplicationContext().getResources();
    DisplayMetrics dm = res.getDisplayMetrics();
    android.content.res.Configuration conf = res.getConfiguration();
    conf.locale = new Locale(lang);
    res.updateConfiguration(conf, dm);
    prefManager.setLanguage(lang.toUpperCase());
    Intent intent = new Intent(ActivitySplashScreen.this, ActivityWelcome.class);
    startActivity(intent);
    finish();
}
 
开发者ID:techstar-cloud,项目名称:techstar-shop,代码行数:17,代码来源:ActivitySplashScreen.java


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