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


Java LocaleList.get方法代码示例

本文整理汇总了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;
}
 
开发者ID:mrprona92,项目名称:SecretBrand,代码行数:18,代码来源:LocaleUtils.java

示例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();
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:14,代码来源:AlphabeticIndexCompat.java

示例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();
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:14,代码来源:AlphabeticIndexCompat.java

示例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;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:10,代码来源:DateTimePickerDialog.java

示例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;
}
 
开发者ID:murraycu,项目名称:android-galaxyzoo,代码行数:36,代码来源:Singleton.java


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