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);
      }
    }
  }
  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();
          }
        });
  }
  private View getHalfTheAudienceAgainstListItemView(
      final HalfTheAudienceAgainstInformation halfTheAudienceAgainstInformation, final int index) {
    View itemView =
        LayoutInflater.from(context).inflate(R.layout.buy_jc_main_listview_item_others, null);
    /** add by yejc 20130823 start */
    final LinearLayout layout = (LinearLayout) itemView.findViewById(R.id.jc_play_detail_layout);
    View divider = (View) itemView.findViewById(R.id.jc_main_divider_up);
    if (index == 0) {
      divider.setVisibility(View.VISIBLE);
    } else {
      divider.setVisibility(View.GONE);
    }
    /** add by yejc 20130823 end */
    // 联赛名称
    TextView leagueTextView = (TextView) itemView.findViewById(R.id.game_name);
    leagueTextView.setText(halfTheAudienceAgainstInformation.getLeague());
    // 比赛时间
    TextView gameDateTextView = (TextView) itemView.findViewById(R.id.game_date);
    StringBuffer gameDate = new StringBuffer();
    gameDate
        .append("编号:")
        .append(halfTheAudienceAgainstInformation.getTeamId())
        .append("\n")
        .append(PublicMethod.getEndTime(halfTheAudienceAgainstInformation.getEndTime()))
        .append("(截)");

    gameDateTextView.setText(gameDate);
    // 主队
    TextView homeTeamTextView = (TextView) itemView.findViewById(R.id.home_team_name);
    homeTeamTextView.setText(halfTheAudienceAgainstInformation.getHomeTeam());
    // VS
    TextView vsTextView = (TextView) itemView.findViewById(R.id.game_vs);
    // 客队
    TextView guestTeamTextView = (TextView) itemView.findViewById(R.id.guest_team_name);
    guestTeamTextView.setText(halfTheAudienceAgainstInformation.getGuestTeam());

    // 胆
    final Button danTextButton = (Button) itemView.findViewById(R.id.game_dan);
    if (halfTheAudienceAgainstInformation.isDan()) {
      danTextButton.setBackgroundResource(R.drawable.jc_btn_b);
      danTextButton.setTextColor(white);
    } else {
      danTextButton.setBackgroundResource(android.R.color.transparent);
      danTextButton.setTextColor(black);
    }

    danTextButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (halfTheAudienceAgainstInformation.isDan()) {
              halfTheAudienceAgainstInformation.setDan(false);
              danTextButton.setBackgroundResource(android.R.color.transparent);
              danTextButton.setTextColor(black);
            } else {
              if (isSelectDanLegal()) {
                halfTheAudienceAgainstInformation.setDan(true);
                danTextButton.setBackgroundResource(R.drawable.jc_btn_b);
                danTextButton.setTextColor(white);
              }
            }

            ((BeiJingSingleGameActivity) context).refreshSelectNumAndDanNum();
          }

          private boolean isSelectDanLegal() {
            if (halfTheAudienceAgainstInformation.getClickNum() > 0) {
              int selectDanNum = getSelectDanNum();
              if (selectDanNum < MAX_DAN) {
                int selectedTeamNum = getSelectedTeamNum();

                if (selectedTeamNum < 3) {
                  Toast.makeText(context, "请您至少选择3场比赛,才能设胆", Toast.LENGTH_SHORT).show();
                  return false;
                } else if (selectDanNum < (selectedTeamNum - 2)) {
                  return true;
                } else {
                  Toast.makeText(
                          context, "胆码不能超过" + (selectedTeamNum - 2) + "个", Toast.LENGTH_SHORT)
                      .show();
                  return false;
                }
              } else {
                Toast.makeText(context, "您最多可以选择" + MAX_DAN + "场比赛进行设胆!", Toast.LENGTH_SHORT)
                    .show();
                return false;
              }
            } else {
              return false;
            }
          }

          private int getSelectedTeamNum() {
            int selectTeamNum = 0;

            for (int list_i = 0; list_i < halfTheAudienceAgainstInformationList.size(); list_i++) {
              List<HalfTheAudienceAgainstInformation> halfTheAudienceAgainstInformations =
                  halfTheAudienceAgainstInformationList.get(list_i);
              for (int list_j = 0; list_j < halfTheAudienceAgainstInformations.size(); list_j++) {
                HalfTheAudienceAgainstInformation hahalfTheAudienceAgainstInformation =
                    halfTheAudienceAgainstInformations.get(list_j);
                if (hahalfTheAudienceAgainstInformation.getClickNum() > 0) {
                  selectTeamNum++;
                }
              }
            }

            return selectTeamNum;
          }

          private int getSelectDanNum() {
            int selectDanNum = 0;

            for (int list_i = 0; list_i < halfTheAudienceAgainstInformationList.size(); list_i++) {
              List<HalfTheAudienceAgainstInformation> halfTheAudienceAgainstInformations =
                  halfTheAudienceAgainstInformationList.get(list_i);
              for (int list_j = 0; list_j < halfTheAudienceAgainstInformations.size(); list_j++) {
                HalfTheAudienceAgainstInformation halfTheAudienceAgainstInformation =
                    halfTheAudienceAgainstInformations.get(list_j);
                if (halfTheAudienceAgainstInformation.isDan()) {
                  selectDanNum++;
                }
              }
            }

            return selectDanNum;
          }
        });

    // 投注按钮
    Button bettingButton = (Button) itemView.findViewById(R.id.jc_main_list_item_button);
    bettingButton.setTag(halfTheAudienceAgainstInformation);
    bettingButton.setEllipsize(TextUtils.TruncateAt.END);

    StringBuilder selectedString = new StringBuilder();
    boolean[] isClicks = halfTheAudienceAgainstInformation.getIsClicks();
    for (int button_i = 0; button_i < SELECT_BUTTON_NUM; button_i++) {
      if (isClicks[button_i] == true) {
        selectedString.append(selectButtonTitles[button_i]).append(" ");
      }
    }

    if (selectedString.length() != 0) {
      bettingButton.setText(selectedString.toString());
    } else {
      bettingButton.setText("");
    }
    bettingButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (((BeiJingSingleGameActivity) context).isSelectedEventNumLegal()
                || halfTheAudienceAgainstInformation.isSelected()) {
              createHalfTheAudienceSelectDialog(v, layout, index);
            } else {
              Toast.makeText(context, "您最多可以选择10场比赛进行投注!", Toast.LENGTH_SHORT).show();
            }
          }
        });

    // 析
    TextView analysisTextView = (TextView) itemView.findViewById(R.id.game_analysis);
    analysisTextView.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            trunExplain(getEvent(halfTheAudienceAgainstInformation));
          }
        });

    return itemView;
  }
  private View getHalfTheAudienceAgainstListItemView(
      final HalfTheAudienceAgainstInformation halfTheAudienceAgainstInformation) {
    View itemView =
        LayoutInflater.from(context).inflate(R.layout.buy_jc_main_listview_item_others, null);
    // 联赛名称
    TextView leagueTextView = (TextView) itemView.findViewById(R.id.game_name);
    leagueTextView.setText(halfTheAudienceAgainstInformation.getLeague());
    // 比赛时间
    TextView gameDateTextView = (TextView) itemView.findViewById(R.id.game_date);
    StringBuffer gameDate = new StringBuffer();
    gameDate
        .append("编号:")
        .append(halfTheAudienceAgainstInformation.getTeamId())
        .append("\n")
        .append(halfTheAudienceAgainstInformation.getEndTime())
        .append("(截)");
    gameDateTextView.setText(gameDate);
    // 主队
    TextView homeTeamTextView = (TextView) itemView.findViewById(R.id.home_team_name);
    homeTeamTextView.setText(halfTheAudienceAgainstInformation.getHomeTeam());
    // VS
    TextView vsTextView = (TextView) itemView.findViewById(R.id.game_vs);
    // 客队
    TextView guestTeamTextView = (TextView) itemView.findViewById(R.id.guest_team_name);
    guestTeamTextView.setText(halfTheAudienceAgainstInformation.getGuestTeam());
    // 投注按钮
    Button bettingButton = (Button) itemView.findViewById(R.id.jc_main_list_item_button);
    bettingButton.setTag(halfTheAudienceAgainstInformation);
    bettingButton.setEllipsize(TextUtils.TruncateAt.END);

    StringBuilder selectedString = new StringBuilder();
    boolean[] isClicks = halfTheAudienceAgainstInformation.getIsClicks();
    for (int button_i = 0; button_i < SELECT_BUTTON_NUM; button_i++) {
      if (isClicks[button_i] == true) {
        selectedString.append(selectButtonTitles[button_i]).append(" ");
      }
    }

    if (selectedString.length() != 0) {
      bettingButton.setText(selectedString.toString());
    } else {
      bettingButton.setText("");
    }
    bettingButton.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (((BeiJingSingleGameActivity) context).isSelectedEventNumLegal()
                || halfTheAudienceAgainstInformation.isSelected()) {
              createHalfTheAudienceSelectDialog(v);
            } else {
              Toast.makeText(context, "您最多可以选择10场比赛进行投注!", Toast.LENGTH_SHORT).show();
            }
          }
        });
    /** close by yejc 20130514 start */
    //		// 析
    //		TextView analysisTextView = (TextView) itemView
    //				.findViewById(R.id.game_analysis);
    //		analysisTextView.setVisibility(View.GONE);
    //		// 胆
    //		Button danTextButton = (Button) itemView.findViewById(R.id.game_dan);
    //		danTextButton.setVisibility(View.GONE);
    /** close by yejc 20130514 end */

    /** add by yejc 20130514 start */
    LinearLayout analysisAndDanLayout = (LinearLayout) itemView.findViewById(R.id.linearLayout3);
    analysisAndDanLayout.setVisibility(View.GONE);
    /** add by yejc 20130514 end */
    return itemView;
  }