【问题标题】:How to get a list of countries and their cities?如何获取国家及其城市的列表?
【发布时间】:2016-04-04 10:00:36
【问题描述】:

谁能帮我获取国家列表和城市列表? 有没有 google Api 来获取这些列表?

【问题讨论】:

标签: android google-api


【解决方案1】:

试试这个:

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());

}

并将列表设置为适配器。

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

参考这些链接:

1) List of countries and their cities in android

2) Retrieve a list of countries from the android OS

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 1970-01-01
    • 1970-01-01
    • 2013-02-08
    • 2011-10-18
    相关资源
    最近更新 更多