如何获得国家及其城市的列表?

kar*_*hik 2 android google-api

任何人都可以帮助我获得一份国家名单和一份他们的城市名单吗?是否有任何用于获取这些列表的 google Api?

Däñ*_*rmà 5

试试这个:

ArrayList<String> list=new ArrayList<String>();

String[] locales = Locale.getISOCountries();

for (String countryCode : locales) {

    Locale obj = new Locale("", countryCode);

    System.out.println("Country Name = " + obj.getDisplayCountry());
    list.add(obj.getDisplayCountry());

}
Run Code Online (Sandbox Code Playgroud)

并将列表设置为适配器。

我认为要获得城市,您必须使用网络服务。

请参阅这些链接:

1) android 中的国家和城市列表

2)从安卓操作系统中检索国家列表