时人不识凌云木,直待凌云始道高。这篇文章主要讲述Android开源库美团等APP城市选择相关的知识,希望能为你提供帮助。
CityPicker现在使用比较多的类似美团等APP的城市选择界面.
2步即可实现,就是这么简单粗暴!
Gif
文章图片
imageAPK下载demo.apk体验.
InstallGradle:
compile ‘com.zaaach:citypicker:1.1‘
or Maven:
<
dependency>
<
groupId>
com.zaaach<
/groupId>
<
artifactId>
citypicker<
/artifactId>
<
version>
1.1<
/version>
<
type>
pom<
/type>
<
/dependency>
or 下载library手动导入.
Usage
CityPicker
本身已经引入了高德地图定位sdk.step1:
在你项目的
manifest.xml
中添加开发平台申请的key<
meta-data android:name="com.amap.api.v2.apikey"
android:value="https://www.songbingjia.com/android/your key"/>
还需要添加
CityPickerActivity
<
activity
android:name="com.zaaach.citypicker.CityPickerActivity"
android:theme="@style/CityPicker.NoActionBar"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustPan"/>
Step2
private static final int REQUEST_CODE_PICK_CITY = 0;
//启动
startActivityForResult(new Intent(MainActivity.this, CityPickerActivity.class),
REQUEST_CODE_PICK_CITY);
//重写onActivityResult方法
@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.**{*;
}
GitHub【Android开源库美团等APP城市选择】github地址:CityPicker欢迎star~
作者:Bro0cL
链接:https://www.jianshu.com/p/b469c6f02754
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
推荐阅读
- android thread / udp socket sample
- android studio 清空缓存插件
- mybatis通用mapper源码解析
- DeepLearning.ai-Week4-Face Recognition for the Happy House
- Android系统的智能指针(轻量级指针强指针和弱指针)的实现原理分析
- Spring Boot 整合 Apache Solr 异常:Expected mime type application/octet-stream but got text/html 的解决.
- 实例化Flask的参数 及 对app的配置
- tomcat 虚拟目录配置appBase和docBase的区别
- android 桌面通知notify