开源软件名称:CityPicker
开源软件地址:https://gitee.com/yuqi101/city-picker
开源软件介绍:
CityPicker 用于城市选择器,仿京东收货地址样式,城市数据会持续更新,烦请留意。 支持 Level1省级、Level2省市级、Level3省市县、Level4省市县镇 共四个级别的条件选择。 组件中使用到 Gson(implementation 'com.google.code.gson:gson:2.8.7') ,如有依赖冲突请留意解决。
效果图:
使用方法 allprojects { repositories { ... maven { url 'https://jitpack.io' } } } dependencies { implementation 'com.gitee.yuqi101:city-picker:1.0.1' } CityPickerDialog.Build(context) .setLevel(level) // 设置联动等级,默认3级联动(CITY_PICKER_LEVEL3) // 添加回调监听 .setAddressListener(new CityPickerDialog.AddressListener() { @Override public void callBack(int level, ProvinceEntity province, CityEntity city, AreaEntity area, TownEntity town) { if(level == CityPickerDialog.CITY_PICKER_LEVEL1){ result_tv.setText("您选择的地址:" + province.provinceName); } else if(level == CityPickerDialog.CITY_PICKER_LEVEL2){ result_tv.setText("您选择的地址:" + province.provinceName + city.cityName); } else if(level == CityPickerDialog.CITY_PICKER_LEVEL3){ result_tv.setText("您选择的地址:" + province.provinceName + city.cityName + area.areaName); } else if(level == CityPickerDialog.CITY_PICKER_LEVEL4){ result_tv.setText("您选择的地址:" + province.provinceName + city.cityName + area.areaName + town.townName); } } }) .setTitle("请选择地址") // 设置标题,默认不显示 .setTitleColor(R.color.text_999) // 设置标题的颜色,默认 #999999 .setSelectColor(R.color.primary) // 设置选中的颜色,默认 #FB593D .setDefaultColor(R.color.text_color) // 设置未选中的颜色,默认 #333333 .setLineColor(R.color.primary) // 设置选中的线的颜色,默认 #FB593D .show(); LicenseCopyright (C) Guoxin, CityPicker Open Source ProjectLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. |
请发表评论