仿京东省市区三级联动
compile 'com.cool:cityselect:1.0.2'
- 弹dialog的形式
new CitySelect(this)
.setMainColor(Color.RED)
.listener(new CitySelect.OnSelectListener() {
@Override
public void onSelect(String province, String city, String area) {
Log.e("399",province + " " + city + " " + area);
Toast.makeText(MainActivity.this,province + " " + city + " " + area,Toast.LENGTH_SHORT).show();
}
}).dialog()
.show();
- 布局中使用
if(mContainer.getChildCount() != 0){
mContainer.removeAllViews();
}
CitySelect citySelect = new CitySelect(this)
.setMainColor(Color.RED);
citySelect.listener(new CitySelect.OnSelectListener() {
@Override
public void onSelect(String province, String city, String area) {
Log.e("399",province + " " + city + " " + area);
Toast.makeText(MainActivity.this,province + " " + city + " " + area,Toast.LENGTH_SHORT).show();
}
});
mContainer.addView(citySelect.getView());
}
setProvinceData(List<Province> provinces)
特别感谢 _有时丶提供数据来源