/** 初始化单选按钮组 */ public void initRadioGroup() { baoRadioGroup = (RadioGroup) findViewById(R.id.buy_join_radiogroup_baodi); for (int i = 0; i < baoTitle.length; i++) { RadioButton radio = new RadioButton(this); radio.setText(baoTitle[i]); radio.setTextColor(Color.BLACK); radio.setTextSize(13); radio.setId(i); radio.setButtonDrawable(R.drawable.radio_select); radio.setPadding(Constants.PADDING, 0, 10, 0); baoRadioGroup.addView(radio); } baoRadioGroup.setOnCheckedChangeListener(this); baoRadioGroup.check(1); openRadioGroup = (RadioGroup) findViewById(R.id.buy_join_radiogroup_open); for (int i = 0; i < openTitle.length; i++) { RadioButton radio = new RadioButton(this); radio.setText(openTitle[i]); radio.setTextColor(Color.BLACK); radio.setTextSize(13); radio.setId(i); radio.setButtonDrawable(R.drawable.radio_select); radio.setPadding(Constants.PADDING, 0, 10, 0); openRadioGroup.addView(radio); } openRadioGroup.setOnCheckedChangeListener(this); openRadioGroup.check(0); }
public void initTopButton() { for (int i = 0; i < topTitle.length; i++) { RadioButton radio = new RadioButton(this); radio.setText(topTitle[i]); radio.setTextColor(Color.BLACK); radio.setTextSize(13); radio.setId(i); radio.setButtonDrawable(R.drawable.radio_select); radio.setPadding(Constants.PADDING, 0, 10, 0); topButton.addView(radio); } }
/** 初始化单选按钮组 */ public void initRadioGroup() { topButton = (RadioGroup) findViewById(R.id.buy_zixuan_radiogroup_top); for (int i = 0; i < topTitle.length; i++) { RadioButton radio = new RadioButton(this); radio.setText(topTitle[i]); radio.setTextColor(Color.BLACK); radio.setTextSize(13); radio.setId(i); radio.setButtonDrawable(R.drawable.radio_select); radio.setPadding(Constants.PADDING, 0, 6, 0); topButton.addView(radio); } topButton.setOnCheckedChangeListener(this); topButton.check(0); }
/** * 单复式投注调用函数 * * @param string 显示框信息 * @return */ public void alert(String string, final String zhuma) { codeStr = zhuma; isGift = false; isJoin = false; isTouzhu = true; LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.alert_dialog_touzhu, null); LinearLayout layout = (LinearLayout) v.findViewById(R.id.alert_dialog_touzhu_linear_qihao_beishu); layout.setVisibility(LinearLayout.GONE); final AlertDialog dialog = new AlertDialog.Builder(this).setTitle("您选择的是").create(); dialog.show(); TextView text = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_one); text.setText(string); TextView textZhuma = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_zhuma); textZhuma.setText(zhuma); Button cancel = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_cancel); Button ok = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_ok); cancel.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub dialog.cancel(); } }); ok.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); initBetPojo(); // TODO Auto-generated method stub if (isGift) { toActivity(zhuma); } else if (isJoin) { toJoinActivity(); } else if (isTouzhu) { touZhuNet(); } } }); check = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu_check); joinCheck = (RadioButton) v.findViewById(R.id.alert_dialog_join_check); RadioButton touzhuCheck = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu1_check); touzhuCheck.setChecked(true); TextView textAlert = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_alert); check.setPadding(50, 0, 0, 0); check.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 check.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isGift = isChecked; } }); joinCheck.setPadding(50, 0, 0, 0); joinCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 joinCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isJoin = isChecked; } }); touzhuCheck.setPadding(50, 0, 0, 0); touzhuCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 touzhuCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isTouzhu = isChecked; } }); dialog.getWindow().setContentView(v); }
/** * 加载每一行的单选按钮 * * @param layoutMain * @param line * @param lineNum */ private void addLine( LinearLayout layoutMain, int line, int lineNum, int isDanNum, int danTeamNum, int teamNum, final boolean isBeijing) { LinearLayout layoutOne = new LinearLayout(context); int id = 0; int last = getNum(teamNum - 1, true); boolean isCheck = isLastCheck(teamNum, danTeamNum); for (int j = 0; j < lineNum; j++) { id = line * this.LineNum + j; RadioButton radio = new RadioButton(context); if (id < isDanNum) { radio.setEnabled(false); radio.setTextColor(Color.GRAY); radio.setButtonDrawable(R.drawable.radio_select); } else if (!isCheck && id >= last) { radio.setEnabled(false); radio.setTextColor(Color.GRAY); radio.setButtonDrawable(R.drawable.radio_select); } else { radio.setTextColor(Color.BLACK); radio.setButtonDrawable(R.drawable.radio_select); } if (isBeijing) { radio.setText(beijingTextId[id]); } else { radio.setText(radioTextId[id]); } int width = PublicMethod.getDisplayWidth(context); if (width == 720) { radio.setTextSize(PublicMethod.getPxInt(7, context)); } else if (width == 640) { radio.setTextSize(PublicMethod.getPxInt(7, context)); } else if (width == 240) { radio.setTextSize(PublicMethod.getPxInt(20, context)); } else if (width == 320) { radio.setTextSize(PublicMethod.getPxInt(15, context)); } else if (width == 800) { radio.setTextSize(PublicMethod.getPxInt(8, context)); } else { radio.setTextSize(PublicMethod.getPxInt(10, context)); } if (Constants.SCREEN_HEIGHT == 854) { radio.setTextSize(PublicMethod.getPxInt(8, context)); } radio.setId(id); radio.setPadding(PublicMethod.getPxInt(20, context), 0, 0, 0); int withPx = PublicMethod.getPxInt(75, context); // 将dip换算成px radio.setLayoutParams(new LayoutParams(withPx, LayoutParams.WRAP_CONTENT)); radio.setOnCheckedChangeListener( new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (isBeijing) { ((BeiJingSingleGameIndentActivity) context).bettingNum = getBeijingRadioZhu(buttonView.getText().toString()); ((BeiJingSingleGameIndentActivity) context).setBettingInformationShow(); } else { touzhuDialog.zhuShu = getRadioZhu(buttonView.getText().toString()); touzhuDialog.setAlertText(); setRadioPrize(buttonView.getText().toString()); } clearRadio(buttonView); } } }); radioBtns.add(radio); layoutOne.addView(radio); } layoutMain.addView(layoutOne); }
/** 第一次启动投注提示框 */ public void initTouZhuDialog() { LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.alert_dialog_touzhu_new, null); touZhuDialog = new Dialog(this, R.style.MyDialog); initImageView(v); if (betAndGift.isZhui()) { initZhuiJia(v); } issueText = (TextView) v.findViewById(R.id.alert_dialog_touzhu_textview_qihao); alertText = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_one); textZhuma = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_zhuma); textTitle = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_zhuma_title); addView.getCodeList().get(addView.getSize() - 1).setTextCodeColor(textZhuma, null, null); issueText.setText(PublicMethod.toIssue(betAndGift.getLotno()) + "期"); alertText.setText(getTouzhuAlert()); textTitle.setText("注码:" + "共有" + addView.getSize() + "笔投注"); Button cancel = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_cancel); Button ok = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_ok); codeInfo = (Button) v.findViewById(R.id.alert_dialog_touzhu_btn_look_code); isCodeText(codeInfo); codeInfo.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub addView.createCodeInfoDialog(); addView.showDialog(); } }); cancel.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub toLogin = false; touZhuDialog.cancel(); clearProgress(); } }); ok.setOnClickListener( new OnClickListener() { public void onClick(View v) { RWSharedPreferences pre = new RWSharedPreferences(ZixuanActivity.this, "addInfo"); sessionId = pre.getStringValue("sessionid"); phonenum = pre.getStringValue("phonenum"); userno = pre.getStringValue("userno"); if (userno.equals("")) { toLogin = true; Intent intentSession = new Intent(ZixuanActivity.this, UserLogin.class); startActivityForResult(intentSession, 0); } else { touZhu(); } } }); CheckBox checkPrize = (CheckBox) v.findViewById(R.id.alert_dialog_touzhu_check_prize); checkPrize.setChecked(true); // 设置betAndGift.prizeend与checkPrize保持一致 betAndGift.setPrizeend("1"); checkPrize.setButtonDrawable(R.drawable.check_on_off); checkPrize.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if (isChecked) { betAndGift.setPrizeend("1"); } else { betAndGift.setPrizeend("0"); } } }); check = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu_check); joinCheck = (RadioButton) v.findViewById(R.id.alert_dialog_join_check); touzhuCheck = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu1_check); touzhuCheck.setChecked(true); textAlert = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_alert); check.setPadding(50, 0, 0, 0); check.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 check.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isGift = isChecked; } }); joinCheck.setPadding(50, 0, 0, 0); joinCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 joinCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isJoin = isChecked; } }); touzhuCheck.setPadding(50, 0, 0, 0); touzhuCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 touzhuCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isTouzhu = isChecked; } }); stateCheck(); touZhuDialog.setCancelable(false); touZhuDialog.setContentView(v); touZhuDialog.show(); }
/** 第一次启动投注提示框 */ public void initTouZhuDialog() { LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.alert_dialog_touzhu_new, null); touZhuDialog = new AlertDialog.Builder(this).setTitle("您选择的是").create(); touZhuDialog.show(); initImageView(v); if (betAndGift.isZhui()) { initZhuiJia(v); } issueText = (TextView) v.findViewById(R.id.alert_dialog_touzhu_textview_qihao); alertText = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_one); textZhuma = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_zhuma); addView.getCodeList().get(addView.getSize() - 1).setTextCodeColor(textZhuma); textTitle = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_zhuma_title); textTitle.setText("注码:" + "共有" + addView.getSize() + "笔投注"); issueText.setText(PublicMethod.toIssue(betAndGift.getLotno()) + "期"); alertText.setText(getTouzhuAlertJixuan()); Button cancel = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_cancel); Button ok = (Button) v.findViewById(R.id.alert_dialog_touzhu_button_ok); codeInfo = (Button) v.findViewById(R.id.alert_dialog_touzhu_btn_look_code); isCodeText(codeInfo); codeInfo.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub addView.createCodeInfoDialog(); addView.showDialog(); } }); cancel.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub touZhuDialog.cancel(); toLogin = false; clearProgress(); } }); ok.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { toLogin = false; initBet(); touZhuDialog.cancel(); // TODO Auto-generated method stub if (isGift) { String code = addView.getsharezhuma(); toActivity(code); } else if (isJoin) { toJoinActivity(); } else if (isTouzhu) { touZhuNet(); } clearProgress(); } }); CheckBox checkPrize = (CheckBox) v.findViewById(R.id.alert_dialog_touzhu_check_prize); checkPrize.setChecked(true); checkPrize.setButtonDrawable(R.drawable.check_on_off); checkPrize.setOnCheckedChangeListener( new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if (isChecked) { betAndGift.setPrizeend("1"); } else { betAndGift.setPrizeend("0"); } } }); check = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu_check); joinCheck = (RadioButton) v.findViewById(R.id.alert_dialog_join_check); touzhuCheck = (RadioButton) v.findViewById(R.id.alert_dialog_touzhu1_check); touzhuCheck.setChecked(true); textAlert = (TextView) v.findViewById(R.id.alert_dialog_touzhu_text_alert); check.setPadding(50, 0, 0, 0); check.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 check.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isGift = isChecked; } }); joinCheck.setPadding(50, 0, 0, 0); joinCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 joinCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isJoin = isChecked; } }); touzhuCheck.setPadding(50, 0, 0, 0); touzhuCheck.setButtonDrawable(R.drawable.check_select); // 实现记住密码 和 复选框的状态 touzhuCheck.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isTouzhu = isChecked; } }); stateCheck(); touZhuDialog.setCancelable(false); touZhuDialog.getWindow().setContentView(v); }