CityPicker
现在使用比较多的类似美团等APP的城市选择界面.
2步即可实现,就是这么简单粗暴!
Gif
image
APK
下载体验.
Install
Gradle:
compile 'com.zaaach:citypicker:1.1'
or Maven:
com.zaaach citypicker 1.1 pom
or 下载library手动导入.
Usage
CityPicker
本身已经引入了高德地图定位sdk.
step1:
在你项目的manifest.xml
中添加开发平台申请的key
还需要添加CityPickerActivity
Step2
private static final int REQUEST_CODE_PICK_CITY = 233; private TextView resultTV; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mychengshi); resultTV = (TextView) findViewById(R.id.tv_result); findViewById(R.id.btn_select).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivityForResult(new Intent(Mychengshi.this, CityPickerActivity.class), REQUEST_CODE_PICK_CITY); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_CODE_PICK_CITY && resultCode == RESULT_OK){ if (data != null){ String city = data.getStringExtra(CityPickerActivity.KEY_PICKED_CITY); resultTV.setText("当前选择:" + city); } } }}
Step3:
enjoy it.
Proguard
注意混淆
#定位-keep class com.amap.api.location.**{*;}-keep class com.amap.api.fence.**{*;}-keep class com.autonavi.aps.amapapi.model.**{*;}作者:这条鱼有点甜 链接:http://www.jianshu.com/p/b469c6f02754 來源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。