本文整理汇总了Java中android.os.LocaleList.get方法的典型用法代码示例。如果您正苦于以下问题:Java LocaleList.get方法的具体用法?Java LocaleList.get怎么用?Java LocaleList.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.LocaleList
的用法示例。
在下文中一共展示了LocaleList.get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDefault
import android.os.LocaleList; //导入方法依赖的package包/类
public static List<Locale> getDefault(Context context, boolean getAllIfPossible) {
List<Locale> list = new ArrayList();
if (VERSION.SDK_INT >= 24) {
LocaleList locales = context.getResources().getConfiguration().getLocales();
for (int i = 0; i < locales.size(); i++) {
Locale locale = locales.get(i);
if (!getAllIfPossible) {
list.add(locale);
break;
}
list.add(locale);
}
} else {
list.add(context.getResources().getConfiguration().locale);
}
return list;
}
示例2: AlphabeticIndexVN
import android.os.LocaleList; //导入方法依赖的package包/类
AlphabeticIndexVN(Context context) {
LocaleList locales = context.getResources().getConfiguration().getLocales();
int localeCount = locales.size();
Locale primaryLocale = localeCount == 0 ? Locale.ENGLISH : locales.get(0);
AlphabeticIndex indexBuilder = new AlphabeticIndex(primaryLocale);
for (int i = 1; i < localeCount; i++) {
indexBuilder.addLabels(locales.get(i));
}
indexBuilder.addLabels(Locale.ENGLISH);
mAlphabeticIndex = indexBuilder.buildImmutableIndex();
}
示例3: AlphabeticIndexVN
import android.os.LocaleList; //导入方法依赖的package包/类
public AlphabeticIndexVN(Context context) {
LocaleList locales = context.getResources().getConfiguration().getLocales();
int localeCount = locales.size();
Locale primaryLocale = localeCount == 0 ? Locale.ENGLISH : locales.get(0);
AlphabeticIndex indexBuilder = new AlphabeticIndex(primaryLocale);
for (int i = 1; i < localeCount; i++) {
indexBuilder.addLabels(locales.get(i));
}
indexBuilder.addLabels(Locale.ENGLISH);
mAlphabeticIndex = indexBuilder.buildImmutableIndex();
}
示例4: getLocale
import android.os.LocaleList; //导入方法依赖的package包/类
private Locale getLocale() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
LocaleList locales = getConfiguration().getLocales();
if (locales.size() > 0) {
return locales.get(0);
}
}
return getConfiguration().locale;
}
示例5: getLocaleDetails
import android.os.LocaleList; //导入方法依赖的package包/类
private static LocaleDetails getLocaleDetails(final Context context) {
final Configuration config = context.getResources().getConfiguration();
if (config == null) {
return null;
}
Locale locale = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
final LocaleList locales = config.getLocales();
if (locales == null || locales.isEmpty()) {
return null;
}
locale = locales.get(0);
} else {
//noinspection deprecation
locale = config.locale;
}
if (locale == null) {
return null;
}
final LocaleDetails result = new LocaleDetails();
result.language = locale.getLanguage();
//The Galaxy zoo files, such as ch_cn.json are lowercase, instead of having the
//country code in uppercase, such as ch_CN, like normal system locales.
final String country = locale.getCountry();
if (!TextUtils.isEmpty(country)) {
result.countryCode = country.toLowerCase(new Locale(Utils.STRING_LANGUAGE));
}
return result;
}