コード例 #1
0
  private void createHalfTheAudienceSelectDialog(final View v, LinearLayout layout, int index) {
    if (layout.getChildCount() == 0) {
      View dialogView = LayoutInflater.from(context).inflate(R.layout.buy_jc_zq_bqc_layout, null);
      final MyCheckBox[] selectButtons = new MyCheckBox[SELECT_BUTTON_NUM];
      final HalfTheAudienceAgainstInformation halfTheAudienceAgainstInformation =
          (HalfTheAudienceAgainstInformation) v.getTag();
      StringBuilder titleString = new StringBuilder();
      titleString
          .append(halfTheAudienceAgainstInformation.getHomeTeam())
          .append(" VS ")
          .append(halfTheAudienceAgainstInformation.getGuestTeam());

      Handler handler =
          new Handler() {
            @Override
            public void handleMessage(Message msg) {
              super.handleMessage(msg);
              String btnStr = "";
              for (int i = 0; i < halfTheAudienceAgainstInformation.getIsClicks().length; i++) {
                if (selectButtons[i].getChecked()) {
                  btnStr += selectButtons[i].getChcekTitle() + "  ";
                  halfTheAudienceAgainstInformation.getIsClicks()[i] = true;
                } else {
                  halfTheAudienceAgainstInformation.getIsClicks()[i] = false;
                }
              }
              ((Button) v).setText(btnStr);

              ((BeiJingSingleGameActivity) context).refreshSelectNumAndDanNum();

              if (halfTheAudienceAgainstInformation.isDan()
                  && !halfTheAudienceAgainstInformation.isSelected()) {
                halfTheAudienceAgainstInformation.setDan(false);
              }
            }
          };

      /** 选择按钮的资源Id */
      int[] selectButtonIds = {
        R.id.lq_sfc_dialog_check01,
        R.id.lq_sfc_dialog_check02,
        R.id.lq_sfc_dialog_check03,
        R.id.lq_sfc_dialog_check04,
        R.id.lq_sfc_dialog_check05,
        R.id.lq_sfc_dialog_check06,
        R.id.lq_sfc_dialog_check07,
        R.id.lq_sfc_dialog_check08,
        R.id.lq_sfc_dialog_check09,
      };
      /** 选择按钮sp */
      String selectButtonSPs[] = {
        halfTheAudienceAgainstInformation.getHalf_v33(),
        halfTheAudienceAgainstInformation.getHalf_v31(),
        halfTheAudienceAgainstInformation.getHalf_v30(),
        halfTheAudienceAgainstInformation.getHalf_v13(),
        halfTheAudienceAgainstInformation.getHalf_v11(),
        halfTheAudienceAgainstInformation.getHalf_v10(),
        halfTheAudienceAgainstInformation.getHalf_v03(),
        halfTheAudienceAgainstInformation.getHalf_v01(),
        halfTheAudienceAgainstInformation.getHalf_v00()
      };

      /** 选择对话框选择按钮 */
      for (int button_i = 0; button_i < SELECT_BUTTON_NUM; button_i++) {
        selectButtons[button_i] = (MyCheckBox) dialogView.findViewById(selectButtonIds[button_i]);
        selectButtons[button_i].setVisibility(CheckBox.VISIBLE);
        selectButtons[button_i].setCheckText(selectButtonSPs[button_i]);
        selectButtons[button_i].setPosition(button_i);
        selectButtons[button_i].setChecked(
            halfTheAudienceAgainstInformation.getIsClicks()[button_i]);
        selectButtons[button_i].setCheckTitle(selectButtonTitles[button_i]);
        selectButtons[button_i].setHandler(handler);
      }

      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
      if (index == 0) {
        RelativeLayout.LayoutParams lParams =
            new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        lParams.setMargins(0, PublicMethod.getPxInt(68.5f, context), 0, 0);
        layout.setLayoutParams(lParams);
      }
      layout.addView(dialogView, params);
      layout.setVisibility(View.VISIBLE);
    } else {
      if (layout.getVisibility() == View.VISIBLE) {
        layout.setVisibility(View.GONE);
      } else {
        layout.setVisibility(View.VISIBLE);
      }
    }
  }
コード例 #2
0
  private void createHalfTheAudienceSelectDialog(View v) {
    View dialogView = LayoutInflater.from(context).inflate(R.layout.buy_lq_sfc_dialog, null);
    final Dialog selectDialog = new AlertDialog.Builder(context).create();

    // 标题
    TextView titleTextView = (TextView) dialogView.findViewById(R.id.layout_main_text_title);
    final HalfTheAudienceAgainstInformation halfTheAudienceAgainstInformation =
        (HalfTheAudienceAgainstInformation) v.getTag();
    StringBuilder titleString = new StringBuilder();
    titleString
        .append(halfTheAudienceAgainstInformation.getHomeTeam())
        .append(" VS ")
        .append(halfTheAudienceAgainstInformation.getGuestTeam());
    titleTextView.setText(titleString);

    /** 选择按钮的资源Id */
    int[] selectButtonIds = {
      R.id.lq_sfc_dialog_check01,
      R.id.lq_sfc_dialog_check02,
      R.id.lq_sfc_dialog_check03,
      R.id.lq_sfc_dialog_check04,
      R.id.lq_sfc_dialog_check05,
      R.id.lq_sfc_dialog_check06,
      R.id.lq_sfc_dialog_check07,
      R.id.lq_sfc_dialog_check08,
      R.id.lq_sfc_dialog_check09,
    };
    /** 选择按钮sp */
    String selectButtonSPs[] = {
      halfTheAudienceAgainstInformation.getHalf_v33(),
      halfTheAudienceAgainstInformation.getHalf_v31(),
      halfTheAudienceAgainstInformation.getHalf_v30(),
      halfTheAudienceAgainstInformation.getHalf_v13(),
      halfTheAudienceAgainstInformation.getHalf_v11(),
      halfTheAudienceAgainstInformation.getHalf_v10(),
      halfTheAudienceAgainstInformation.getHalf_v03(),
      halfTheAudienceAgainstInformation.getHalf_v01(),
      halfTheAudienceAgainstInformation.getHalf_v00()
    };

    /** 选择对话框选择按钮 */
    final MyCheckBox[] selectButtons = new MyCheckBox[SELECT_BUTTON_NUM];
    for (int button_i = 0; button_i < SELECT_BUTTON_NUM; button_i++) {
      selectButtons[button_i] = (MyCheckBox) dialogView.findViewById(selectButtonIds[button_i]);
      selectButtons[button_i].setVisibility(CheckBox.VISIBLE);
      selectButtons[button_i].setCheckText(selectButtonSPs[button_i]);
      selectButtons[button_i].setPosition(button_i);
      selectButtons[button_i].setChecked(halfTheAudienceAgainstInformation.getIsClicks()[button_i]);
      selectButtons[button_i].setCheckTitle(selectButtonTitles[button_i]);
    }

    selectDialog.show();
    selectDialog.getWindow().setContentView(dialogView);

    Button okButton = (Button) dialogView.findViewById(R.id.ok);
    okButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            for (int button_i = 0; button_i < SELECT_BUTTON_NUM; button_i++) {
              MyCheckBox selectButton = selectButtons[button_i];
              if (selectButton.getChecked() == true) {
                halfTheAudienceAgainstInformation.getIsClicks()[button_i] = true;
              } else {
                halfTheAudienceAgainstInformation.getIsClicks()[button_i] = false;
              }
            }
            selectDialog.dismiss();
            ((BeiJingSingleGameActivity) context).refreshAgainstInformationShow(false, false);
            ((BeiJingSingleGameActivity) context).refreshSelectNum();
          }
        });
    Button cancelButton = (Button) dialogView.findViewById(R.id.canel);
    cancelButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            boolean[] isClicks = halfTheAudienceAgainstInformation.getIsClicks();
            for (int i = 0; i < isClicks.length; i++) {
              isClicks[i] = false;
            }
            ((BeiJingSingleGameActivity) context).refreshAgainstInformationShow(false, false);
            ((BeiJingSingleGameActivity) context).refreshSelectNum();
            selectDialog.dismiss();
          }
        });
  }