Android的 - 获取支持的区域设置列表 [英] Android - Get List of supported Locales
本文介绍了Android的 - 获取支持的区域设置列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要实现自动完成的TextView
为 Android设备的所有支持语言环境。我试过如下:
I have to implement AutoComplete TextView
for all the supported locales
of Android Device. I tried the following:
public class AutoCompleteView extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, Locales);
AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.locale_list);
textView.setAdapter(adapter);
}
static Locale[] locales = Locale.getAvailableLocales();
private static final String[] Locales = ;
}
我可以使用区域设置[]
来获取语言环境。在code的最后一行,如何解析到的String []语言环境
..请帮我的朋友......
I am able to get the locales using Locale[]
. In the last line of code, How to parse that to String[] Locales
.. Please help me friends....
推荐答案
对不起,迟到的答复
试试这个
Locale[] locales = Locale.getAvailableLocales();
ArrayList<String> localcountries=new ArrayList<String>();
for(Locale l:locales)
{
localcountries.add(l.getDisplayLanguage().toString());
}
String[] languages=(String[]) localcountries.toArray(new String[localcountries.size()]);
我希望这会帮助你。
I hope this will help you.
这篇关于Android的 - 获取支持的区域设置列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文