Exemplo n.º 1
0
  /** 为周期选择初始化数据 */
  private void initData() {
    String[] weekstr = {"星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"};
    overalllist = new ArrayList<WeekDialog>();

    for (int i = 0; i < weekstr.length; i++) {
      weekDialog = new WeekDialog();
      weekDialog.setWeek(weekstr[i]);
      weekDialog.setChecked(false);
      overalllist.add(weekDialog);
    }
  }
Exemplo n.º 2
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

      if (convertView == null) {
        convertView = LayoutInflater.from(mContext).inflate(R.layout.itemweek, null);
      }
      TextView tvUserName = (TextView) convertView.findViewById(R.id.dispatch_item_select_week);
      final CheckBox ckbItem = (CheckBox) convertView.findViewById(R.id.dispatch_item_select_state);
      WeekDialog week = list.get(position);
      tvUserName.setText(week.getWeek());

      ckbItem.setChecked(week.isChecked());
      // 将选择状态保存在overalllist中
      ckbItem.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              overalllist.get(position).setChecked(ckbItem.isChecked());
            }
          });
      week = null;
      return convertView;
    }