コード例 #1
0
 /**
  * 只要是年月发生变化,就要去检查日是否也联动发生变化(比如有些年份二月28天,有些年份是29天)
  *
  * @param mYearWheelView2
  * @param mMonthWheelView2
  * @param mDayWheelView2 void
  */
 private void updateDays(WheelView year, WheelView month, WheelView day) {
   // 选择的年月对应的那个月总共有多少天
   Calendar calendar = Calendar.getInstance();
   calendar.set(Calendar.YEAR, year.getCurrentItem());
   calendar.set(Calendar.MONTH, month.getCurrentItem());
   mMaxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
   mDayAdapter =
       new WheelNumericAdapter(this, 1, mMaxDay, getString(R.string.putao_personal_data_day));
   mDayWheelView.setViewAdapter(mDayAdapter);
 }
コード例 #2
0
 /** 当省份滑动改变时,相应的改变城市 void */
 private void updateCities() {
   // 获取当前选中省份的索引
   int currentIndex = mProvinceWheelView.getCurrentItem();
   ProvinceItem currentProvince = mProvinceItems.get(currentIndex);
   LinkedList<String> cityList = currentProvince.cityList;
   // 清空城市列表
   mCitiesList.clear();
   if (cityList != null && cityList.size() > 0) {
     mCitiesList.addAll(cityList);
   } else {
     mCitiesList.add("---");
   }
   mCityAdapter.setData(mCitiesList);
   mCityWheelView.setCurrentItem(0);
 }