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


Java Configuration.setLayoutDirection方法代码示例

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


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

示例1: updateResourcesLegacy

import android.content.res.Configuration; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private static Context updateResourcesLegacy(Context context, String language) {
	Locale locale = new Locale(language);
	Locale.setDefault(locale);

	Resources resources = context.getResources();

	Configuration configuration = resources.getConfiguration();
	configuration.locale = locale;
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
		configuration.setLayoutDirection(locale);
	}

	resources.updateConfiguration(configuration, resources.getDisplayMetrics());

	return context;
}
 
开发者ID:joaomneto,项目名称:TitanCompanion,代码行数:18,代码来源:LocaleHelper.java

示例2: setContextLocale

import android.content.res.Configuration; //导入方法依赖的package包/类
private static void setContextLocale(Context context, Locale selectedLocale) {
  Configuration configuration = context.getResources().getConfiguration();

  if (!configuration.locale.equals(selectedLocale)) {
    configuration.locale = selectedLocale;
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR1) {
      configuration.setLayoutDirection(selectedLocale);
    }
    context.getResources().updateConfiguration(configuration,
                                               context.getResources().getDisplayMetrics());
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:13,代码来源:DynamicLanguage.java

示例3: updateLocale

import android.content.res.Configuration; //导入方法依赖的package包/类
private void updateLocale(@NonNull Context context, @NonNull Locale locale) {
  final Resources resources = context.getResources();
  Configuration config = resources.getConfiguration();
  config.locale = locale;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
    config.setLayoutDirection(config.locale);
  }
  resources.updateConfiguration(config, resources.getDisplayMetrics());
}
 
开发者ID:Elias33,项目名称:Quran,代码行数:10,代码来源:QuranApplication.java

示例4: updateLocale

import android.content.res.Configuration; //导入方法依赖的package包/类
private void updateLocale(@NonNull Context context, @NonNull Locale locale) {
    final Resources resources = context.getResources();
    Configuration config = resources.getConfiguration();
    config.locale = locale;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        config.setLayoutDirection(config.locale);
    }
    resources.updateConfiguration(config, resources.getDisplayMetrics());
}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:10,代码来源:IslamicLibraryApplication.java

示例5: updateResources

import android.content.res.Configuration; //导入方法依赖的package包/类
public static Context updateResources(Context context, Locale locale) {
    Locale.setDefault(locale);
    Resources resources = context.getResources();
    Configuration configuration = resources.getConfiguration();
    configuration.setLayoutDirection(locale);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        configuration.setLocale(locale);
        return context.createConfigurationContext(configuration);
    } else {
        configuration.locale = locale;
        resources.updateConfiguration(configuration, resources.getDisplayMetrics());
        return context;
    }
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:15,代码来源:LocaleUtils.java

示例6: updateResources

import android.content.res.Configuration; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.N)
private static Context updateResources(Context context, String language) {
	Locale locale = new Locale(language);
	Locale.setDefault(locale);

	Configuration configuration = context.getResources().getConfiguration();
	configuration.setLocale(locale);
	configuration.setLayoutDirection(locale);

	return context.createConfigurationContext(configuration);
}
 
开发者ID:joaomneto,项目名称:TitanCompanion,代码行数:12,代码来源:LocaleHelper.java

示例7: updateConfiguration

import android.content.res.Configuration; //导入方法依赖的package包/类
/**
 * This is public to allow for an activity to force the
 * current locale to be applied if necessary (e.g., when
 * a new activity launches).
 */
public void updateConfiguration(Context context, Locale locale) {
    Resources res = context.getResources();
    Configuration config = res.getConfiguration();

    // We should use setLocale, but it's unexpectedly missing
    // on real devices.
    config.locale = locale;

    config.setLayoutDirection(locale);

    res.updateConfiguration(config, null);
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:18,代码来源:LocaleManager.java


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