最后我得到了我一直在寻找后很多脑hamering.this的给我的名单被下的langauge和输入设置显示汉语语言
public void getLangs()
{
String[] systemLocaleIetfLanguageTags = getAssets().getLocales();
Arrays.sort(systemLocaleIetfLanguageTags);
this.data = new ArrayList();
for (String ietfLanguageTag : systemLocaleIetfLanguageTags)
{
if (ietfLanguageTag != null && ietfLanguageTag.length() == 5)
{
this.data.add(new Loc(ietfLanguageTag));
}
}
}
还可以创建一个类来获得所有的语言
public class Loc {
protected Locale locale;
public Loc(String ietfLanguageTag) {
this.locale = null;
String[] l = ietfLanguageTag.split("_");
if (l.length == 2) {
this.locale = new Locale(l[0], l[1]);
}
}
public String oneLineLanguageCountry() {
return String.format("%s (%s)", new Object[]{toTitleCase(this.locale.getDisplayLanguage(this.locale)), toTitleCase(this.locale.getDisplayCountry(this.locale))});
}
public String twoLinesLanguageCountry() {
return String.format("%s\n%s", new Object[]{toTitleCase(this.locale.getDisplayLanguage(this.locale)), toTitleCase(this.locale.getDisplayCountry(this.locale))});
}
public String getIetfLanguageTag() {
return String.format("%s_%s", new Object[]{this.locale.getLanguage(), this.locale.getCountry()});
}
public Locale getLocale() {
return this.locale;
}
private static String toTitleCase(String s) {
return s.length() == 0 ? s : new StringBuilder(String.valueOf(Character.toUpperCase(s.charAt(0)))).append(s.substring(1)).toString();
}
public boolean isLocaleCurrentLocale() {
return Locale.getDefault().equals(getLocale());
}
public String toString() {
return oneLineLanguageCountry();
}
}
请投我的答案,如果它也适合你
对不起,我不明白你,你可以更明确吗?你期望得到什么? –
是的,现在当你进入你的设备设置,你会看到设置语言和输入里面,你有语言点击你将得到的语言列表。 – tanmeet
我希望在我的应用中获得相同的列表 – tanmeet