作者:何炘柱_549 | 来源:互联网 | 2023-05-24 12:28
第一步:Gradle引用compileliji.library.dev:citypickerview:0.1.0第二步:代码示例CityPickerViewcityPickerViewne
第一步:Gradle引用
compile'liji.library.dev:citypickerview:0.1.0'
第二步:代码示例
CityPickerView cityPickerView = new CityPickerView(MainActivity.this);
cityPickerView.setOnCityItemClickListener(new CityPickerView.OnCityItemClickListener() {
@Override
public void onSelected(String... citySelected) {
//省份
String province = citySelected[0];
//城市
String city = citySelected[1];
//区县
String district = citySelected[2];
//邮编
String code = citySelected[3];
Toast.makeText(MainActivity.this,province+"-"+city+"-"+district,Toast.LENGTH_LONG).show();
}
});
cityPickerView.show();
看效果:
大家直接拿来用即可,是不是方便多了。