仿美团等APP城市选择

这里写图片描述

Install

Gradle:

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="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.**{*;}

demo下载http://download.csdn.net/download/qq_35549248/9930706

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值