标签:out .com sch XML parse parent extend prot instance
依赖
dependencies { ... compile ‘liji.library.dev:citypickerview:0.7.0‘ }
主
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]); } }); } }); }}
布局
<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" > <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>
标签:out .com sch XML parse parent extend prot instance
原文地址:http://www.cnblogs.com/z1998/p/7493754.html