/** 根据当前的省,更新市WheelView的信息 */ private void updateCities() { int pCurrent = mViewProvince.getCurrentItem(); mCurrentProviceName = mProvinceDatas[pCurrent]; String[] cities = mCitisDatasMap.get(mCurrentProviceName); if (cities == null) { cities = new String[] {""}; } mViewCity.setViewAdapter(new ArrayWheelAdapter<String>(this, cities)); mViewCity.setCurrentItem(0); updateAreas(); }
private void setUpData() { initProvinceDatas(); mViewProvince.setViewAdapter( new ArrayWheelAdapter<String>(ChooseCityActivity.this, mProvinceDatas)); // 设置可见条目数量 mViewProvince.setVisibleItems(7); mViewCity.setVisibleItems(7); mViewDistrict.setVisibleItems(7); updateCities(); updateAreas(); }
private void setUpListener() { // 添加change事件 mViewProvince.addChangingListener(this); // 添加change事件 mViewCity.addChangingListener(this); // 添加change事件 mViewDistrict.addChangingListener(this); // 添加onclick事件 mBtnConfirm.setOnClickListener(this); back.setOnClickListener(this); }
/** 根据当前的市,更新区WheelView的信息 */ private void updateAreas() { int pCurrent = mViewCity.getCurrentItem(); mCurrentCityName = mCitisDatasMap.get(mCurrentProviceName)[pCurrent]; String[] areas = mDistrictDatasMap.get(mCurrentCityName); mCurrentDistrictName = mDistrictDatasMap.get(mCurrentCityName)[0]; mCurrentZipCode = mZipcodeDatasMap.get(mCurrentDistrictName); if (areas == null) { areas = new String[] {""}; } mViewDistrict.setViewAdapter(new ArrayWheelAdapter<String>(this, areas)); mViewDistrict.setCurrentItem(0); }