demo链接:https://download.csdn.net/download/meixi_android/10819638
实现效果:
实现方法:非常简洁快速,三步集成实现地区选择器
1、导入city.module
module导入方法:https://blog.csdn.net/meixi_android/article/details/84655666
2、配置地区选择activity
<activityandroid:name="com.zaaach.citypicker.CityPickerActivity"android:theme="@style/CityPicker.NoActionBar"android:screenOrientation="portrait"android:windowSoftInputMode="stateHidden|adjustPan"/>
3、activity起调地区选择activity,获取选择回调结果city
public class MainActivity extends AppCompatActivity {TextView textView;private static final int REQUEST_CODE_PICK_CITY = 0;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);textView = findViewById(R.id.ssssss);textView.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {startActivityForResult(new Intent(MainActivity.this, CityPickerActivity.class),REQUEST_CODE_PICK_CITY);}});}//返回选中城市@Overridepublic 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); // if (!city.equals("全国")) { // city += "市"; // }textView.setText(city);}} else {}}}