예제 #1
0
  public void initData(int regionCode) {
    // 一定能选中省
    provinceAdapter.addHeader(
        (provinceHeader =
            new RegionHeaderView(callback, new Region(0, 1, 100000, 100000, "不限"), "不限")));
    ArrayList<Region> arrProvince = RegionModel.getInstance().getProvinceList();
    provinceAdapter.addAll(arrProvince);
    Region provinceRegion = RegionModel.getInstance().findProvince(regionCode);
    if (provinceRegion == null) {
      provinceRegion = arrProvince.get(0);
    }
    province.scrollToPosition(arrProvince.indexOf(provinceRegion) + 1);

    // 一定要选中市
    cityAdapter.addHeader((cityHeader = new RegionHeaderView(callback, provinceRegion, "全部")));
    ArrayList<Region> arrCity = RegionModel.getInstance().getCityList(provinceRegion.getCid());
    cityAdapter.addAll(arrCity);
    Region cityRegion = RegionModel.getInstance().findCity(regionCode);
    if (cityRegion == null) {
      cityRegion = arrCity.get(0);
    }
    city.scrollToPosition(arrCity.indexOf(cityRegion) + 1);

    // 一定要选中区
    regionAdapter.addHeader((regionHeader = new RegionHeaderView(callback, cityRegion, "全部")));
    ArrayList<Region> arrRegion = RegionModel.getInstance().getRegionList(cityRegion.getCid());
    regionAdapter.addAll(arrRegion);
    Region regionRegion = RegionModel.getInstance().findRegion(regionCode);
    if (regionRegion == null) {
      regionRegion = arrRegion.get(0);
    }
    region.scrollToPosition(arrRegion.indexOf(regionRegion) + 1);
  }
예제 #2
0
 @Override
 public void setData(Region data) {
   rg = data;
   tv.setText(data.getName());
   itemView.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           JUtils.Log("onClick");
           callback.selected(rg);
         }
       });
 }