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