android - 如何获取国家及其城市的列表?

标签 android google-api

谁能帮我得到一份国家名单和他们的城市名单? 是否有用于获取这些列表的任何 google Api?

最佳答案

试试这个:

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

关于android - 如何获取国家及其城市的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36399613/

相关文章:

java - 方法 setLatestEventInfo(GcmMessageHandler, String, String, PendingIntent) 未定义类型通知

android - SSL 握手异常 : Connection closed by peer

c# - 如何列出特定文件夹中的文件夹和文件

python - 如何从备用源创建 Google API OAuth Credentials 对象

firebase - 从 Firebase 函数调用 Google Play Developer API

android - 自定义 Toast 不适用于 ICS

android - Flutter:从 WebView 加载 IFrame

iOS 和谷歌 API

android - 远程媒体播放器 HTTP 响应处理

Android传递值为什么为null?