分别获取国家、城市及其地区/州/镇的列表 [英] Getting list of countries, cities and their areas/states/towns respectively

查看:29
本文介绍了分别获取国家、城市及其地区/州/镇的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在微调器中加载所有国家/地区的列表,然后在选择特定国家/地区时,其所有城市都会出现在另一个微调器中,选择城市后,我们会在其中获得该城市的地区或城镇列表android 使用 google-api 或类似国家/地区选择器的东西?目前我正在使用它来获取国家/地区列表.但是如何获得各自的城镇?

Is this possible to load a list of all countries in a spinner, then on selecting the particular country, all of its cities appears in another spinner and after selecting the city, we get the list of areas or towns of that city in android using google-api or something like country picker? Currently i am using this to get the list of countries. but how to get their respective cities and towns?

    ArrayList<String> list=new ArrayList<String>();
String[] locales = Locale.getISOCountries();
for (String countryCode : locales) {
    Locale obj = new Locale("", countryCode);
    list.add(obj.getDisplayCountry());
}

推荐答案

您可以使用可用的 JSON 文件 这里.只需将其添加到您的项目的 assets 文件夹中,并在解析后将城市和国家/地区列表添加到微调器中.

You can use the JSON file available here. Just add it to your project into the assets folder and add the list of cities and countries to spinner after parsing it.

这篇关于分别获取国家、城市及其地区/州/镇的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆