PickerView(二级联动)

最近新学会了一个技能  不敢说写的详细所以在此贴上大佬的博客地址

借鉴博客 写的很详细

写这篇博客的目的有两个 一个是为了自己后期来看 另一个是为了让有需要的朋友看看我懵懵懂懂犯下的错 跳过一些误区 节省时间

废话不多说 下边开始正题

2020/1/14更新


PickerView框架:实现联动很方便 一级二级三级都差不多 

先上一个二级联动的图

PickerView(二级联动)_第1张图片

 任务是把一个json.txt的文件解析 实现二级联动

1、先导依赖:

//Gson解析
    implementation 'com.google.code.gson:gson:2.8.1'
    //PickerView联动框架
    implementation 'com.contrarywind:Android-PickerView:4.1.8'

2、在main文件夹下创建assets的文件夹用于放保存地址数据的json文件city.json。city.json文件里的内容会附在最后。效果如下。

需要把 .txt 文件改为 .json 


3、然后建一个实体类 (GsonFormat  /就是ALT+S) 记得实现   IPickerViewData 不然后果很严重

(一级列表白板/严重卡顿/内存溢出 )别问我是怎么知道的


public class TextBean implements IPickerViewData {

。。。下边我就不粘了

然后需要重写一个方法 (name是你一级列表需要显示的那个en...成员变量)


    @Override
    public String getPickerViewText() {
        return this.name;
    }

4、这是一个可以将json文件里的数据转换成json字符串的工具类(这个直接用就行 后边代码已经调用了 完全不用管)

package com.example.lin.mylanya.three;

import android.content.Context;
import android.content.res.AssetManager;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class GetJsonDataUtil {

    public String getJson(Context context, String fileName) {

        StringBuilder stringBuilder = new StringBuilder();
        try {
            AssetManager assetManager = context.getAssets();
            BufferedReader bf = new BufferedReader(new InputStreamReader(
                    assetManager.open(fileName)));
            String line;
            while ((line = bf.readLine()) != null) {
                stringBuilder.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stringBuilder.toString();
    }
}

5、解析数据

先new联动需要的集合  

private ArrayList options1Items = new ArrayList<>();//一级
    private ArrayList> options2Items = new ArrayList<>();//二级
//    private ArrayList>> options3Items = new ArrayList<>();//三级
  private String province;
    private String city;
    private final int MSG_LOAD_DATA = 0;
    private final int MSG_LOAD_SUCCESS = 1;
    private final int MSG_LOAD_FAILED = 2;
    private Thread thread;

解析数据的方法 

我这边的方法是直接把gson转成的实体赋值给一级列表的集合了 

//解析数据
    private void initJsonData() {
        /**
         * 注意:assets 目录下的Json文件仅供参考,实际使用可自行替换文件
         * 关键逻辑在于循环体
         * 获取assets目录下的json文件数据
         */
        String CityData = new GetJsonDataUtil().getJson(this, "city.json");
        //用Gson 转成实体
        options1Items = parseData(CityData);
        /**
         * 添加省份数据
         * 注意:如果是添加的JavaBean实体,则实体类需要实现 IPickerViewData 接口,
         * PickerView会通过getPickerViewText方法获取字符串显示出来。
         * 遍历省份
         */
        for (int i = 0; i < options1Items.size(); i++) {
            //该省的城市列表(第二级)
            ArrayList CityList = new ArrayList<>();
            //遍历该省份的所有城市
            for (int i1 = 0; i1 < options1Items.get(i).getCityBeanList().size(); i1++) {
                String name = options1Items.get(i).getCityBeanList().get(i1).getName();
                //添加城市
                CityList.add(name);
            }
            /**
             * 添加城市数据
             * 把二级放入一级
             */
            options2Items.add(CityList);
        }
        mHandler.sendEmptyMessage(MSG_LOAD_SUCCESS);

    }

还有一个把Gson转成实体类的方法 不用改直接用就行

 //Gson 解析
    public ArrayList parseData(String result) {
        ArrayList detail = new ArrayList<>();
        try {
            JSONArray data = new JSONArray(result);
            Gson gson = new Gson();
            for (int i = 0; i < data.length(); i++) {
                TextBean entity = gson.fromJson(data.optJSONObject(i).toString(), TextBean.class);
                detail.add(entity);
            }
        } catch (Exception e) {
            e.printStackTrace();
            mHandler.sendEmptyMessage(MSG_LOAD_FAILED);
        }
        return detail;
    }

到目前位置一级二级的集合都已经放入值了 


6、PickerView 划重点。。。

看了好几个博客都是17年的 导入的依赖和现在的不太一样 所以写法也稍微有点差别 (具体差别可以对比上别我贴出的大佬博客)

这是现在的用法   

// 弹出地址选择器
    private void ShowPickerView() {
        OptionsPickerView pvOptions = new OptionsPickerBuilder(this, new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                province = options1Items.get(options1).getName();
                city = options2Items.get(options1).get(options2);
//                        + options3Items.get(options1).get(options2).get(options3);
                //选定后显示  显示的位置,也可以从这里取值 mText是一个xml的textview的id
                mText.setText(province + city);
            }
        })
                //这几个值没需求的可以不要
                .setDividerColor(Color.BLACK)
                //设置选中项文字颜色
                .setTextColorCenter(Color.BLACK)
                .setContentTextSize(20)
                // default is true
                .setOutSideCancelable(false)
                .build();//这个不能丢

        //二级选择器(市区)
        pvOptions.setPicker(options1Items, options2Items);
        //pvOptions.setPicker(options1Items, options2Items, options3Items);//三级选择器
        pvOptions.show();
    }

7、因为我们要加载json文件中的数据,这属于耗时操作需要一个子线程,数据加载完毕才能让选择器展示数据。这里免我们用到了Handle解决这个问题。 
(往方法区粘就行)

  //判断地址数据是否获取成功
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_LOAD_DATA:
                    //如果已创建就不再重新创建子线程了
                    if (thread == null) {
                        Log.i("addr", "地址数据开始解析");
                        thread = new Thread(new Runnable() {
                            @Override
                            public void run() {
                                // 写子线程中的操作,解析省市区数据
                                initJsonData();
                            }
                        });
                        thread.start();
                    }
                    break;

                case MSG_LOAD_SUCCESS:
                    Log.i("addr", "地址数据获取成功");
//                    isLoaded = true;
                    break;

                case MSG_LOAD_FAILED:
                    Log.i("addr", "地址数据获取失败");
                    break;
                default:
                    break;
            }
        }
    };

使用时只用在在onCreate()里面启动handle线程 然后在点击事件里调用弹出的方法就可以了

 mHandler.sendEmptyMessage(MSG_LOAD_DATA);

8、city.json

[
    {
        "id": 1,
        "name": "北京",
        "cityBeanList": [
            {
                "id": 1,
                "name": "东城区"
            },
            {
                "id": 2,
                "name": "西城区"
            },
            {
                "id": 3,
                "name": "崇文区"
            },
            {
                "id": 4,
                "name": "宣武区"
            },
            {
                "id": 5,
                "name": "朝阳区"
            },
            {
                "id": 6,
                "name": "丰台区"
            },
            {
                "id": 7,
                "name": "石景山区"
            },
            {
                "id": 8,
                "name": "海淀区"
            },
            {
                "id": 9,
                "name": "门头沟区"
            },
            {
                "id": 10,
                "name": "房山区"
            },
            {
                "id": 11,
                "name": "通州区"
            },
            {
                "id": 12,
                "name": "顺义区"
            },
            {
                "id": 13,
                "name": "昌平区"
            },
            {
                "id": 14,
                "name": "大兴区"
            },
            {
                "id": 15,
                "name": "怀柔区"
            },
            {
                "id": 16,
                "name": "平谷区"
            },
            {
                "id": 17,
                "name": "密云县"
            },
            {
                "id": 18,
                "name": "延庆县"
            }
        ]
    },
    {
        "id": 2,
        "name": "上海",
        "cityBeanList": [
            {
                "id": 107,
                "name": "黄浦区"
            },
            {
                "id": 108,
                "name": "卢湾区"
            },
            {
                "id": 109,
                "name": "徐汇区"
            },
            {
                "id": 110,
                "name": "长宁区"
            },
            {
                "id": 111,
                "name": "静安区"
            },
            {
                "id": 112,
                "name": "普陀区"
            },
            {
                "id": 113,
                "name": "闸北区"
            },
            {
                "id": 114,
                "name": "虹口区"
            },
            {
                "id": 115,
                "name": "杨浦区"
            },
            {
                "id": 116,
                "name": "闵行区"
            },
            {
                "id": 117,
                "name": "宝山区"
            },
            {
                "id": 118,
                "name": "嘉定区"
            },
            {
                "id": 119,
                "name": "浦东新区"
            },
            {
                "id": 120,
                "name": "金山区"
            },
            {
                "id": 121,
                "name": "松江区"
            },
            {
                "id": 122,
                "name": "青浦区"
            },
            {
                "id": 123,
                "name": "南汇区"
            },
            {
                "id": 124,
                "name": "奉贤区"
            },
            {
                "id": 125,
                "name": "崇明县"
            }
        ]
    },
    {
        "id": 3,
        "name": "天津",
        "cityBeanList": [
            {
                "id": 19,
                "name": "和平区"
            },
            {
                "id": 20,
                "name": "河东区"
            },
            {
                "id": 21,
                "name": "河西区"
            },
            {
                "id": 22,
                "name": "南开区"
            },
            {
                "id": 23,
                "name": "河北区"
            },
            {
                "id": 24,
                "name": "红桥区"
            },
            {
                "id": 25,
                "name": "塘沽区"
            },
            {
                "id": 26,
                "name": "汉沽区"
            },
            {
                "id": 27,
                "name": "大港区"
            },
            {
                "id": 28,
                "name": "东丽区"
            },
            {
                "id": 29,
                "name": "西青区"
            },
            {
                "id": 30,
                "name": "津南区"
            },
            {
                "id": 31,
                "name": "北辰区"
            },
            {
                "id": 32,
                "name": "武清区"
            },
            {
                "id": 33,
                "name": "宝坻区"
            },
            {
                "id": 34,
                "name": "宁河县"
            },
            {
                "id": 35,
                "name": "静海县"
            },
            {
                "id": 36,
                "name": "蓟 县"
            }
        ]
    },
    {
        "id": 4,
        "name": "重庆",
        "cityBeanList": [
            {
                "id": 287,
                "name": "万州区"
            },
            {
                "id": 288,
                "name": "涪陵区"
            },
            {
                "id": 289,
                "name": "渝中区"
            },
            {
                "id": 290,
                "name": "大渡口区"
            },
            {
                "id": 291,
                "name": "江北区"
            },
            {
                "id": 292,
                "name": "沙坪坝区"
            },
            {
                "id": 293,
                "name": "九龙坡区"
            },
            {
                "id": 294,
                "name": "南岸区"
            },
            {
                "id": 295,
                "name": "北碚区"
            },
            {
                "id": 296,
                "name": "万盛区"
            },
            {
                "id": 297,
                "name": "双桥区"
            },
            {
                "id": 298,
                "name": "渝北区"
            },
            {
                "id": 299,
                "name": "巴南区"
            },
            {
                "id": 300,
                "name": "黔江区"
            },
            {
                "id": 301,
                "name": "长寿区"
            },
            {
                "id": 302,
                "name": "綦江县"
            },
            {
                "id": 303,
                "name": "潼南县"
            },
            {
                "id": 304,
                "name": "铜梁县"
            },
            {
                "id": 305,
                "name": "大足县"
            },
            {
                "id": 306,
                "name": "荣昌县"
            },
            {
                "id": 307,
                "name": "璧山县"
            },
            {
                "id": 308,
                "name": "梁平县"
            },
            {
                "id": 309,
                "name": "城口县"
            },
            {
                "id": 310,
                "name": "丰都县"
            },
            {
                "id": 311,
                "name": "垫江县"
            },
            {
                "id": 312,
                "name": "武隆县"
            },
            {
                "id": 313,
                "name": "忠 县"
            },
            {
                "id": 314,
                "name": "开 县"
            },
            {
                "id": 315,
                "name": "云阳县"
            },
            {
                "id": 316,
                "name": "奉节县"
            },
            {
                "id": 317,
                "name": "巫山县"
            },
            {
                "id": 318,
                "name": "巫溪县"
            },
            {
                "id": 319,
                "name": "石柱县"
            },
            {
                "id": 320,
                "name": "秀山县"
            },
            {
                "id": 321,
                "name": "酉阳县"
            },
            {
                "id": 322,
                "name": "彭水县"
            },
            {
                "id": 323,
                "name": "江津市"
            },
            {
                "id": 324,
                "name": "合川市"
            },
            {
                "id": 325,
                "name": "永川市"
            },
            {
                "id": 326,
                "name": "南川市"
            }
        ]
    },
    {
        "id": 5,
        "name": "安徽",
        "cityBeanList": [
            {
                "id": 150,
                "name": "合肥"
            },
            {
                "id": 151,
                "name": "芜湖"
            },
            {
                "id": 152,
                "name": "蚌埠"
            },
            {
                "id": 153,
                "name": "淮南"
            },
            {
                "id": 154,
                "name": "马鞍山"
            },
            {
                "id": 155,
                "name": "淮北"
            },
            {
                "id": 156,
                "name": "铜陵"
            },
            {
                "id": 157,
                "name": "安庆"
            },
            {
                "id": 158,
                "name": "黄山"
            },
            {
                "id": 159,
                "name": "滁州"
            },
            {
                "id": 160,
                "name": "阜阳"
            },
            {
                "id": 161,
                "name": "宿州"
            },
            {
                "id": 162,
                "name": "巢湖"
            },
            {
                "id": 163,
                "name": "六安"
            },
            {
                "id": 164,
                "name": "亳州"
            },
            {
                "id": 165,
                "name": "池州"
            },
            {
                "id": 166,
                "name": "宣城"
            }
        ]
    },
    {
        "id": 6,
        "name": "湖南",
        "cityBeanList": [
            {
                "id": 235,
                "name": "长沙"
            },
            {
                "id": 236,
                "name": "株洲"
            },
            {
                "id": 237,
                "name": "湘潭"
            },
            {
                "id": 238,
                "name": "衡阳"
            },
            {
                "id": 239,
                "name": "邵阳"
            },
            {
                "id": 240,
                "name": "岳阳"
            },
            {
                "id": 241,
                "name": "常德"
            },
            {
                "id": 242,
                "name": "张家界"
            },
            {
                "id": 243,
                "name": "益阳"
            },
            {
                "id": 244,
                "name": "郴州"
            },
            {
                "id": 245,
                "name": "永州"
            },
            {
                "id": 246,
                "name": "怀化"
            },
            {
                "id": 247,
                "name": "娄底"
            },
            {
                "id": 248,
                "name": "湘西"
            }
        ]
    },
    {
        "id": 7,
        "name": "湖北",
        "cityBeanList": [
            {
                "id": 221,
                "name": "武汉"
            },
            {
                "id": 222,
                "name": "黄石"
            },
            {
                "id": 223,
                "name": "十堰"
            },
            {
                "id": 224,
                "name": "宜昌"
            },
            {
                "id": 225,
                "name": "襄樊"
            },
            {
                "id": 226,
                "name": "鄂州"
            },
            {
                "id": 227,
                "name": "荆门"
            },
            {
                "id": 228,
                "name": "孝感"
            },
            {
                "id": 229,
                "name": "荆州"
            },
            {
                "id": 230,
                "name": "黄冈"
            },
            {
                "id": 231,
                "name": "咸宁"
            },
            {
                "id": 232,
                "name": "随州"
            },
            {
                "id": 233,
                "name": "恩施"
            }
        ]
    },
    {
        "id": 8,
        "name": "江苏",
        "cityBeanList": [
            {
                "id": 126,
                "name": "南京"
            },
            {
                "id": 127,
                "name": "无锡"
            },
            {
                "id": 128,
                "name": "徐州"
            },
            {
                "id": 129,
                "name": "常州"
            },
            {
                "id": 130,
                "name": "苏州"
            },
            {
                "id": 131,
                "name": "南通"
            },
            {
                "id": 132,
                "name": "连云港"
            },
            {
                "id": 133,
                "name": "淮安"
            },
            {
                "id": 134,
                "name": "盐城"
            },
            {
                "id": 135,
                "name": "扬州"
            },
            {
                "id": 136,
                "name": "镇江"
            },
            {
                "id": 137,
                "name": "泰州"
            },
            {
                "id": 138,
                "name": "宿迁"
            }
        ]
    },
    {
        "id": 9,
        "name": "浙江",
        "cityBeanList": [
            {
                "id": 139,
                "name": "杭州"
            },
            {
                "id": 140,
                "name": "宁波"
            },
            {
                "id": 141,
                "name": "温州"
            },
            {
                "id": 142,
                "name": "嘉兴"
            },
            {
                "id": 143,
                "name": "湖州"
            },
            {
                "id": 144,
                "name": "绍兴"
            },
            {
                "id": 145,
                "name": "金华"
            },
            {
                "id": 146,
                "name": "衢州"
            },
            {
                "id": 147,
                "name": "舟山"
            },
            {
                "id": 148,
                "name": "台州"
            },
            {
                "id": 149,
                "name": "丽水"
            }
        ]
    },
    {
        "id": 10,
        "name": "四川",
        "cityBeanList": [
            {
                "id": 327,
                "name": "成都"
            },
            {
                "id": 328,
                "name": "自贡"
            },
            {
                "id": 329,
                "name": "攀枝花"
            },
            {
                "id": 330,
                "name": "泸州"
            },
            {
                "id": 331,
                "name": "德阳"
            },
            {
                "id": 332,
                "name": "绵阳"
            },
            {
                "id": 333,
                "name": "广元"
            },
            {
                "id": 334,
                "name": "遂宁"
            },
            {
                "id": 335,
                "name": "内江"
            },
            {
                "id": 336,
                "name": "乐山"
            },
            {
                "id": 337,
                "name": "南充"
            },
            {
                "id": 338,
                "name": "眉山"
            },
            {
                "id": 339,
                "name": "宜宾"
            },
            {
                "id": 340,
                "name": "广安"
            },
            {
                "id": 341,
                "name": "达州"
            },
            {
                "id": 342,
                "name": "雅安"
            },
            {
                "id": 343,
                "name": "巴中"
            },
            {
                "id": 344,
                "name": "资阳"
            },
            {
                "id": 345,
                "name": "阿坝"
            },
            {
                "id": 346,
                "name": "甘孜"
            },
            {
                "id": 347,
                "name": "凉山"
            }
        ]
    },
    {
        "id": 11,
        "name": "贵州",
        "cityBeanList": [
            {
                "id": 348,
                "name": "贵阳"
            },
            {
                "id": 349,
                "name": "六盘水"
            },
            {
                "id": 350,
                "name": "遵义"
            },
            {
                "id": 351,
                "name": "安顺"
            },
            {
                "id": 352,
                "name": "铜仁地区"
            },
            {
                "id": 353,
                "name": "黔西南"
            },
            {
                "id": 354,
                "name": "毕节"
            },
            {
                "id": 355,
                "name": "黔东南"
            },
            {
                "id": 356,
                "name": "黔南"
            }
        ]
    },
    {
        "id": 12,
        "name": "甘肃",
        "cityBeanList": [
            {
                "id": 390,
                "name": "兰州"
            },
            {
                "id": 391,
                "name": "嘉峪关"
            },
            {
                "id": 392,
                "name": "金昌"
            },
            {
                "id": 393,
                "name": "白银"
            },
            {
                "id": 394,
                "name": "天水"
            },
            {
                "id": 395,
                "name": "武威"
            },
            {
                "id": 396,
                "name": "张掖"
            },
            {
                "id": 397,
                "name": "平凉"
            },
            {
                "id": 398,
                "name": "酒泉"
            },
            {
                "id": 399,
                "name": "庆阳"
            },
            {
                "id": 400,
                "name": "定西"
            },
            {
                "id": 401,
                "name": "陇南"
            },
            {
                "id": 402,
                "name": "临夏"
            },
            {
                "id": 403,
                "name": "甘南"
            }
        ]
    },
    {
        "id": 13,
        "name": "青海",
        "cityBeanList": [
            {
                "id": 404,
                "name": "西宁"
            },
            {
                "id": 405,
                "name": "海东"
            },
            {
                "id": 406,
                "name": "海北"
            },
            {
                "id": 407,
                "name": "黄南"
            },
            {
                "id": 408,
                "name": "海南"
            },
            {
                "id": 409,
                "name": "果洛"
            },
            {
                "id": 410,
                "name": "玉树"
            },
            {
                "id": 411,
                "name": "海西"
            }
        ]
    },
    {
        "id": 14,
        "name": "山西",
        "cityBeanList": [
            {
                "id": 48,
                "name": "太原"
            },
            {
                "id": 49,
                "name": "大同"
            },
            {
                "id": 50,
                "name": "阳泉"
            },
            {
                "id": 51,
                "name": "长治"
            },
            {
                "id": 52,
                "name": "晋城"
            },
            {
                "id": 53,
                "name": "朔州"
            },
            {
                "id": 54,
                "name": "晋中"
            },
            {
                "id": 55,
                "name": "运城"
            },
            {
                "id": 56,
                "name": "忻州"
            },
            {
                "id": 57,
                "name": "临汾"
            },
            {
                "id": 58,
                "name": "吕梁"
            }
        ]
    },
    {
        "id": 15,
        "name": "山东",
        "cityBeanList": [
            {
                "id": 187,
                "name": "济南"
            },
            {
                "id": 188,
                "name": "青岛"
            },
            {
                "id": 189,
                "name": "淄博"
            },
            {
                "id": 190,
                "name": "枣庄"
            },
            {
                "id": 191,
                "name": "东营"
            },
            {
                "id": 192,
                "name": "烟台"
            },
            {
                "id": 193,
                "name": "潍坊"
            },
            {
                "id": 194,
                "name": "济宁"
            },
            {
                "id": 195,
                "name": "泰安"
            },
            {
                "id": 196,
                "name": "威海"
            },
            {
                "id": 197,
                "name": "日照"
            },
            {
                "id": 198,
                "name": "莱芜"
            },
            {
                "id": 199,
                "name": "临沂"
            },
            {
                "id": 200,
                "name": "德州"
            },
            {
                "id": 201,
                "name": "聊城"
            },
            {
                "id": 202,
                "name": "滨州"
            },
            {
                "id": 203,
                "name": "菏泽"
            }
        ]
    },
    {
        "id": 16,
        "name": "陕西",
        "cityBeanList": [
            {
                "id": 380,
                "name": "西安"
            },
            {
                "id": 381,
                "name": "铜川"
            },
            {
                "id": 382,
                "name": "宝鸡"
            },
            {
                "id": 383,
                "name": "咸阳"
            },
            {
                "id": 384,
                "name": "渭南"
            },
            {
                "id": 385,
                "name": "延安"
            },
            {
                "id": 386,
                "name": "汉中"
            },
            {
                "id": 387,
                "name": "榆林"
            },
            {
                "id": 388,
                "name": "安康"
            },
            {
                "id": 389,
                "name": "商洛"
            }
        ]
    },
    {
        "id": 17,
        "name": "河南",
        "cityBeanList": [
            {
                "id": 204,
                "name": "郑州"
            },
            {
                "id": 205,
                "name": "开封"
            },
            {
                "id": 206,
                "name": "洛阳"
            },
            {
                "id": 207,
                "name": "平顶山"
            },
            {
                "id": 208,
                "name": "安阳"
            },
            {
                "id": 209,
                "name": "鹤壁"
            },
            {
                "id": 210,
                "name": "新乡"
            },
            {
                "id": 211,
                "name": "焦作"
            },
            {
                "id": 212,
                "name": "濮阳"
            },
            {
                "id": 213,
                "name": "许昌"
            },
            {
                "id": 214,
                "name": "漯河"
            },
            {
                "id": 215,
                "name": "三门峡"
            },
            {
                "id": 216,
                "name": "南阳"
            },
            {
                "id": 217,
                "name": "商丘"
            },
            {
                "id": 218,
                "name": "信阳"
            },
            {
                "id": 219,
                "name": "周口"
            },
            {
                "id": 220,
                "name": "驻马店"
            }
        ]
    },
    {
        "id": 18,
        "name": "黑龙江",
        "cityBeanList": [
            {
                "id": 94,
                "name": "哈尔滨"
            },
            {
                "id": 95,
                "name": "齐齐哈尔"
            },
            {
                "id": 96,
                "name": "鸡西"
            },
            {
                "id": 97,
                "name": "鹤岗"
            },
            {
                "id": 98,
                "name": "双鸭山"
            },
            {
                "id": 99,
                "name": "大庆"
            },
            {
                "id": 100,
                "name": "伊春"
            },
            {
                "id": 101,
                "name": "佳木斯"
            },
            {
                "id": 102,
                "name": "七台河"
            },
            {
                "id": 103,
                "name": "牡丹江"
            },
            {
                "id": 104,
                "name": "黑河"
            },
            {
                "id": 105,
                "name": "绥化"
            },
            {
                "id": 106,
                "name": "大兴安岭"
            }
        ]
    },
    {
        "id": 19,
        "name": "河北",
        "cityBeanList": [
            {
                "id": 37,
                "name": "石家庄"
            },
            {
                "id": 38,
                "name": "唐山"
            },
            {
                "id": 39,
                "name": "秦皇岛"
            },
            {
                "id": 40,
                "name": "邯郸"
            },
            {
                "id": 41,
                "name": "邢台"
            },
            {
                "id": 42,
                "name": "保定"
            },
            {
                "id": 43,
                "name": "张家口"
            },
            {
                "id": 44,
                "name": "承德"
            },
            {
                "id": 45,
                "name": "沧州"
            },
            {
                "id": 46,
                "name": "廊坊"
            },
            {
                "id": 47,
                "name": "衡水"
            }
        ]
    },
    {
        "id": 20,
        "name": "福建",
        "cityBeanList": [
            {
                "id": 167,
                "name": "福州"
            },
            {
                "id": 168,
                "name": "厦门"
            },
            {
                "id": 169,
                "name": "莆田"
            },
            {
                "id": 170,
                "name": "三明"
            },
            {
                "id": 171,
                "name": "泉州"
            },
            {
                "id": 172,
                "name": "漳州"
            },
            {
                "id": 173,
                "name": "南平"
            },
            {
                "id": 174,
                "name": "龙岩"
            },
            {
                "id": 175,
                "name": "宁德"
            }
        ]
    },
    {
        "id": 21,
        "name": "云南",
        "cityBeanList": [
            {
                "id": 357,
                "name": "昆明"
            },
            {
                "id": 358,
                "name": "曲靖"
            },
            {
                "id": 359,
                "name": "玉溪"
            },
            {
                "id": 360,
                "name": "保山"
            },
            {
                "id": 361,
                "name": "昭通"
            },
            {
                "id": 362,
                "name": "丽江"
            },
            {
                "id": 363,
                "name": "思茅"
            },
            {
                "id": 364,
                "name": "临沧"
            },
            {
                "id": 365,
                "name": "楚雄"
            },
            {
                "id": 366,
                "name": "红河"
            },
            {
                "id": 367,
                "name": "文山"
            },
            {
                "id": 368,
                "name": "西双版纳"
            },
            {
                "id": 369,
                "name": "大理"
            },
            {
                "id": 370,
                "name": "德宏"
            },
            {
                "id": 371,
                "name": "怒江"
            },
            {
                "id": 372,
                "name": "迪庆"
            }
        ]
    },
    {
        "id": 22,
        "name": "江西",
        "cityBeanList": [
            {
                "id": 176,
                "name": "南昌"
            },
            {
                "id": 177,
                "name": "景德镇"
            },
            {
                "id": 178,
                "name": "萍乡"
            },
            {
                "id": 179,
                "name": "九江"
            },
            {
                "id": 180,
                "name": "新余"
            },
            {
                "id": 181,
                "name": "鹰潭"
            },
            {
                "id": 182,
                "name": "赣州"
            },
            {
                "id": 183,
                "name": "吉安"
            },
            {
                "id": 184,
                "name": "宜春"
            },
            {
                "id": 185,
                "name": "抚州"
            },
            {
                "id": 186,
                "name": "上饶"
            }
        ]
    },
    {
        "id": 23,
        "name": "广东",
        "cityBeanList": [
            {
                "id": 249,
                "name": "广州"
            },
            {
                "id": 250,
                "name": "韶关"
            },
            {
                "id": 251,
                "name": "深圳"
            },
            {
                "id": 252,
                "name": "珠海"
            },
            {
                "id": 253,
                "name": "汕头"
            },
            {
                "id": 254,
                "name": "佛山"
            },
            {
                "id": 255,
                "name": "江门"
            },
            {
                "id": 256,
                "name": "湛江"
            },
            {
                "id": 257,
                "name": "茂名"
            },
            {
                "id": 258,
                "name": "肇庆"
            },
            {
                "id": 259,
                "name": "惠州"
            },
            {
                "id": 260,
                "name": "梅州"
            },
            {
                "id": 261,
                "name": "汕尾"
            },
            {
                "id": 262,
                "name": "河源"
            },
            {
                "id": 263,
                "name": "阳江"
            },
            {
                "id": 264,
                "name": "清远"
            },
            {
                "id": 265,
                "name": "东莞"
            },
            {
                "id": 266,
                "name": "中山"
            },
            {
                "id": 267,
                "name": "潮州"
            },
            {
                "id": 268,
                "name": "揭阳"
            },
            {
                "id": 269,
                "name": "云浮"
            }
        ]
    },
    {
        "id": 24,
        "name": "辽宁",
        "cityBeanList": [
            {
                "id": 71,
                "name": "沈阳"
            },
            {
                "id": 72,
                "name": "大连"
            },
            {
                "id": 73,
                "name": "鞍山"
            },
            {
                "id": 74,
                "name": "抚顺"
            },
            {
                "id": 75,
                "name": "本溪"
            },
            {
                "id": 76,
                "name": "丹东"
            },
            {
                "id": 77,
                "name": "锦州"
            },
            {
                "id": 78,
                "name": "营口"
            },
            {
                "id": 79,
                "name": "阜新"
            },
            {
                "id": 80,
                "name": "辽阳"
            },
            {
                "id": 81,
                "name": "盘锦"
            },
            {
                "id": 82,
                "name": "铁岭"
            },
            {
                "id": 83,
                "name": "朝阳"
            },
            {
                "id": 84,
                "name": "葫芦岛"
            }
        ]
    },
    {
        "id": 25,
        "name": "吉林",
        "cityBeanList": [
            {
                "id": 85,
                "name": "长春"
            },
            {
                "id": 86,
                "name": "吉林"
            },
            {
                "id": 87,
                "name": "四平"
            },
            {
                "id": 88,
                "name": "辽源"
            },
            {
                "id": 89,
                "name": "通化"
            },
            {
                "id": 90,
                "name": "白山"
            },
            {
                "id": 91,
                "name": "松原"
            },
            {
                "id": 92,
                "name": "白城"
            },
            {
                "id": 93,
                "name": "延边"
            }
        ]
    },
    {
        "id": 26,
        "name": "内蒙古",
        "cityBeanList": [
            {
                "id": 59,
                "name": "呼和浩特"
            },
            {
                "id": 60,
                "name": "包头"
            },
            {
                "id": 61,
                "name": "乌海"
            },
            {
                "id": 62,
                "name": "赤峰"
            },
            {
                "id": 63,
                "name": "通辽"
            },
            {
                "id": 64,
                "name": "鄂尔多斯"
            },
            {
                "id": 65,
                "name": "呼伦贝尔"
            },
            {
                "id": 66,
                "name": "巴彦淖尔"
            },
            {
                "id": 67,
                "name": "乌兰察布"
            },
            {
                "id": 68,
                "name": "兴安盟"
            },
            {
                "id": 69,
                "name": "锡林郭勒盟"
            },
            {
                "id": 70,
                "name": "阿拉善盟"
            }
        ]
    },
    {
        "id": 27,
        "name": "广西",
        "cityBeanList": [
            {
                "id": 270,
                "name": "南宁"
            },
            {
                "id": 271,
                "name": "柳州"
            },
            {
                "id": 272,
                "name": "桂林"
            },
            {
                "id": 273,
                "name": "梧州"
            },
            {
                "id": 274,
                "name": "北海"
            },
            {
                "id": 275,
                "name": "防城港"
            },
            {
                "id": 276,
                "name": "钦州"
            },
            {
                "id": 277,
                "name": "贵港"
            },
            {
                "id": 278,
                "name": "玉林"
            },
            {
                "id": 279,
                "name": "百色"
            },
            {
                "id": 280,
                "name": "贺州"
            },
            {
                "id": 281,
                "name": "河池"
            },
            {
                "id": 282,
                "name": "来宾"
            },
            {
                "id": 283,
                "name": "崇左"
            }
        ]
    },
    {
        "id": 28,
        "name": "新疆",
        "cityBeanList": [
            {
                "id": 417,
                "name": "乌鲁木齐"
            },
            {
                "id": 418,
                "name": "克拉玛依"
            },
            {
                "id": 419,
                "name": "吐鲁番"
            },
            {
                "id": 420,
                "name": "哈密"
            },
            {
                "id": 421,
                "name": "昌吉"
            },
            {
                "id": 422,
                "name": "博尔塔拉"
            },
            {
                "id": 423,
                "name": "巴音郭楞"
            },
            {
                "id": 424,
                "name": "阿克苏"
            },
            {
                "id": 425,
                "name": "克孜勒苏柯尔克孜"
            },
            {
                "id": 426,
                "name": "喀什地区"
            },
            {
                "id": 427,
                "name": "和田地区"
            },
            {
                "id": 428,
                "name": "伊犁"
            },
            {
                "id": 429,
                "name": "塔城"
            },
            {
                "id": 430,
                "name": "阿勒泰"
            }
        ]
    },
    {
        "id": 29,
        "name": "西藏",
        "cityBeanList": [
            {
                "id": 373,
                "name": "拉萨"
            },
            {
                "id": 374,
                "name": "昌都"
            },
            {
                "id": 375,
                "name": "山南"
            },
            {
                "id": 376,
                "name": "日喀则"
            },
            {
                "id": 377,
                "name": "那曲"
            },
            {
                "id": 378,
                "name": "阿里"
            },
            {
                "id": 379,
                "name": "林芝"
            }
        ]
    },
    {
        "id": 30,
        "name": "宁夏",
        "cityBeanList": [
            {
                "id": 412,
                "name": "银川"
            },
            {
                "id": 413,
                "name": "石嘴山"
            },
            {
                "id": 414,
                "name": "吴忠"
            },
            {
                "id": 415,
                "name": "固原"
            },
            {
                "id": 416,
                "name": "中卫"
            }
        ]
    },
    {
        "id": 31,
        "name": "海南",
        "cityBeanList": [
            {
                "id": 284,
                "name": "海口"
            },
            {
                "id": 285,
                "name": "三亚"
            }
        ]
    },
    {
        "id": 32,
        "name": "台湾",
        "cityBeanList": [
            {
                "id": 432,
                "name": "台湾"
            }
        ]
    },
    {
        "id": 33,
        "name": "澳门",
        "cityBeanList": [
            {
                "id": 433,
                "name": "澳门"
            }
        ]
    },
    {
        "id": 34,
        "name": "香港",
        "cityBeanList": [
            {
                "id": 434,
                "name": "香港"
            }
        ]
    }
]

 

 

 

 

你可能感兴趣的:(PickerView(二级联动))