AndroidPicker icon indicating copy to clipboard operation
AndroidPicker copied to clipboard

关于地址三级联动问题

Open 18819318753 opened this issue 8 years ago • 6 comments

你好,大神,我碰见了些问题,麻烦你看看是怎么回事。 我的设置是这样的 addressPicker = new AddressPicker(this, (ArrayList<Province>) AddressJsonUtils.initJsonData(context)); addressPicker.setHideProvince(false); addressPicker.setHideCounty(false); addressPicker.setTitleText("城市选择"); addressPicker.setTextSize(Dp2PxUtil.px2dip(context, 50)); addressPicker.setTitleTextSize(Dp2PxUtil.px2dip(context, 50)); addressPicker.setCancelTextSize(Dp2PxUtil.px2dip(context, 50)); addressPicker.setSubmitTextSize(Dp2PxUtil.px2dip(context, 50)); addressPicker.setLineColor(Color.parseColor("#B40000")); addressPicker.setSubmitTextColor(Color.parseColor("#B40000")); addressPicker.setCancelTextColor(Color.parseColor("#B40000")); addressPicker.setCycleDisable(true); addressPicker.setTextColor(Color.parseColor("#B40000"), Color.parseColor("#cccccc")); addressPicker.setTitleTextColor(Color.parseColor("#cccccc")); addressPicker.setTopLineColor(Color.parseColor("#B40000")); addressPicker.setTopLineVisible(true); addressPicker.show();

   我看你的例子,有哪个AddressPickTack这个,可是我找不到,能解答一下吗?

qq 20170922174213

18819318753 avatar Sep 22 '17 09:09 18819318753

就是我想要有三级,可是无论怎么弄都是只有两级

18819318753 avatar Sep 22 '17 09:09 18819318753

@18819318753

(ArrayList) AddressJsonUtils.initJsonData(context)

你的数据里没有初始化第三级的吧

liyujiang-gzu avatar Sep 22 '17 10:09 liyujiang-gzu

你可以参考这个初始化方式:

        ArrayList<Province> data = new ArrayList<>();
        List<ProvinceResponse> provinces;
        if (onlyTwo) {
            provinces = FileUtils.getProvincesIncludeQuanGuo(activity);
        } else {
            provinces = FileUtils.getProvinces(activity);
        }
        for (int i = 0, size = provinces.size(); i < size; i++) {
            ProvinceResponse p = provinces.get(i);
            Province pro = new Province();
            pro.setAreaId(p.getCode());
            pro.setAreaName(p.getName());
            List<CityResponse> cityResponseList = p.getCity();
            List<City> cities = new ArrayList<>();
            for (int j = 0; j < cityResponseList.size(); j++) {
                CityResponse c = cityResponseList.get(j);
                City cit = new City();
                cit.setAreaId(c.getCode());
                cit.setAreaName(c.getName());
                List<AreaResponse> areaResponseList = c.getArea();
                List<County> counties = new ArrayList<>();
                for (AreaResponse a : areaResponseList) {
                    County cou = new County();
                    cou.setAreaId(a.getCode());
                    cou.setAreaName(a.getName());
                    counties.add(cou);
                }
                //香港、澳门、海南等的第三级可能没数据
                if (counties.size() == 0) {
                    counties.add(new County("-"));
                }
                cit.setCounties(counties);
                cities.add(cit);
            }
            //台湾的第二三级居然没数据?
            if (cities.size() == 0) {
                City cit = new City("-");
                List<County> counties = new ArrayList<>();
                counties.add(new County("-"));
                cit.setCounties(counties);
                cities.add(cit);
            }
            pro.setCities(cities);
            data.add(pro);
        }
        AddressPicker picker = new AddressPicker(activity, data);

AddressPickTask

liyujiang-gzu avatar Sep 22 '17 10:09 liyujiang-gzu

你好,还是不行呢。你能看一下是怎么回事吗?我logcat能打印第三级的数据。

18819318753 avatar Sep 23 '17 02:09 18819318753

你确定你的“”北京“”这些直辖市真有第三级数据?不显示说明是没数据的呀

liyujiang-gzu avatar Oct 16 '17 01:10 liyujiang-gzu

只要第一个modle(东城区)没有第三级数据,下面的所有数据都不显示第三级,不管它有没有第三级

ghost avatar Jan 15 '19 10:01 ghost