Comments (2)
1.5.X版本已经支持传入对象,详见demo
from androidpicker.
你好, 为什么是对象..... 我想说直接支持ID查找 .....
public void onAddressPicker(View view) {
AddressPickTask task = new AddressPickTask(this);
task.setHideProvince(false);
task.setHideCounty(false);
task.setCallback(new AddressPickTask.Callback() {
@Override
public void onAddressInitFailed() {
showToast("数据初始化失败");
}
@Override
public void onAddressPicked(Province province, City city, County county) {
if (county == null) {
showToast(province.getAreaName() + city.getAreaName());
} else {
showToast(province.getAreaName() + city.getAreaName() + county.getAreaName());
}
}
});
task.execute("贵州", "毕节", "纳雍");
}
public void onAddress2Picker(View view) {
try {
ArrayList<Province> data = new ArrayList<>();
String json = ConvertUtils.toString(getAssets().open("city2.json"));
data.addAll(JSON.parseArray(json, Province.class));
AddressPicker picker = new AddressPicker(this, data);
picker.setShadowVisible(true);
picker.setHideProvince(true);
picker.setSelectedItem("贵州", "贵阳", "花溪");
picker.setOnAddressPickListener(new AddressPicker.OnAddressPickListener() {
@Override
public void onAddressPicked(Province province, City city, County county) {
showToast("province : " + province + ", city: " + city + ", county: " + county);
}
});
picker.show();
} catch (Exception e) {
showToast(LogUtils.toStackTraceString(e));
}
}
public void onAddress3Picker(View view) {
AddressPickTask task = new AddressPickTask(this);
task.setHideCounty(true);
task.setCallback(new AddressPickTask.Callback() {
@Override
public void onAddressInitFailed() {
showToast("数据初始化失败");
}
@Override
public void onAddressPicked(Province province, City city, County county) {
showToast(province.getAreaName() + " " + city.getAreaName());
}
});
task.execute("四川", "阿坝");
}
已知服务器存储的是名称对应的ID, eg. 贵州=520000 , 一般情况下, 服务器是返回 520000", "520100" "520111" ,
转换对象是直接 New Province province, City city, County county ... 然后传入ID
我觉得这层可以封装呀 .... 直接接收传入ID , eg. picker.setSelectedItemID("520000", "520100" "520111");
from androidpicker.
Related Issues (20)
- 当DialogStyle为Three时想要自定义单项选择器的位置怎么操作呢 HOT 1
- 是否可以后续支持年月日时这样的格式 HOT 1
- 日期选择器是否有自动进位的功能
- 文件选择器为什么只显示文件夹不显示文件 HOT 12
- 求助!为什么日期选择器不显示内容 HOT 1
- 「BugReport」WheelView的drawItemText方法会导致ANR HOT 2
- 日历无法选择同一天 HOT 1
- 设置大字体后的样式问题
- 选择器不显示问题。
- ImagePicker在Fragment上有使用示例吗? HOT 2
- 12小时制setRange不对问题
- 日历日期选择多选时范围指定前几几个月 选择的时候默认显示的是开始的日期 HOT 1
- 更新 china_address.json 的操作方法,获取到最新版的省市区数据 HOT 1
- TimeMode设置为None时,DatimeWheelLayout显示内容无法居中 HOT 1
- 在时间选择器中 上下滚动夸循环日期时,是否可以让月份随之加减 HOT 2
- 滚轮选择器-数字选择器 当参数为float型时,会出现精度丢失问题 HOT 1
- 避免maskView导致的内存泄露 HOT 1
- 圆角和样式 HOT 1
- 可以不保留分秒吗? HOT 2
- 支持registerForActivityResult
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidpicker.