导入依赖
compile 'liji.library.dev:citypickerview:0.3.0'
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" > <Button android:id="@+id/go" android:layout_width="match_parent" android:layout_height="60dp" android:text="选择省市区" /> <TextView android:id="@+id/tv_result" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/go" android:layout_marginTop="10dp" android:text="选择结果:" android:textSize="20sp" /> </RelativeLayout>主Activity代码package com.example.longfei.sanji_city; import android.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import com.lljjcoder.citypickerview.widget.CityPicker; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button go = (Button) findViewById(R.id.go); final TextView tvResult = (TextView) findViewById(R.id.tv_result); go.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CityPicker cityPicker = new CityPicker.Builder(MainActivity.this).textSize(20) .textColor(Color.parseColor("#000000")) .provinceCyclic(true) .cityCyclic(false) .districtCyclic(false) .visibleItemsCount(7) .itemPadding(10) .build(); cityPicker.show(); cityPicker.setOnCityItemClickListener(new CityPicker.OnCityItemClickListener() { @Override public void onSelected(String... citySelected) { tvResult.setText("选择结果:\n省:" + citySelected[0] + "\n市:" + citySelected[1] + "\n区:" + citySelected[2] + "\n邮编:" + citySelected[3]); } }); } }); } } 补充内容:最珍贵的地址https://github.com/crazyandcoder/citypickerCityPicker cityPicker = new CityPicker.Builder(context).textSize(20)//滚轮文字的大小 .textColor(Color.parseColor("#000000"))//滚轮文字的颜色 .provinceCyclic(true)//省份滚轮是否循环显示 .cityCyclic(false)//城市滚轮是否循环显示 .districtCyclic(false)//地区(县)滚轮是否循环显示 .visibleItemsCount(7)//滚轮显示的item个数 .itemPadding(10)//滚轮item间距 .build(); cityPicker.show(); cityPicker.setOnCityItemClickListener(new CityPicker.OnCityItemClickListener() { @Override public void onSelected(String... citySelected) { //省份 String province = citySelected[0]; //城市 String city = citySelected[1]; //区县 String district = citySelected[2]; //邮编 String code = citySelected[3]; } });