private void select3_Dialog(String s ){ amount = s; LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view_P = inflater.inflate(R.layout.diag_pay3, null); s_Dialog = new Dialog(this,R.style.dialog); s_Dialog.setContentView(view_P); s_Dialog.setCancelable(false); //s_Dialog.setCanceledOnTouchOutside(true); TextView tv_title = (TextView)view_P.findViewById(R.id.dg_title_p); tv_title.setText("充值"+ Integer.parseInt(amount)/100 +"元,选择支付方式"); final RadioGroup RadioGroup01 = (RadioGroup)view_P.findViewById(R.id.RadioGroup01); RadioButton rb1 = (RadioButton)view_P.findViewById(R.id.rbt_1); RadioButton rb2 = (RadioButton)view_P.findViewById(R.id.rbt_2); RadioButton rb3 = (RadioButton)view_P.findViewById(R.id.rbt_3); Button dg_button_ok = (Button)view_P.findViewById(R.id.dg_button_ok_p); Button dg_button_cancel= (Button)view_P.findViewById(R.id.dg_button_cancel_p); RadioGroup01.setOnCheckedChangeListener(new OnCheckedChangeListener () { public void onCheckedChanged(RadioGroup arg0, int checkedId) { if(checkedId==R.id.rbt_1){ Toast.makeText(Activitycharge.this,"A选中", Toast.LENGTH_LONG).show(); select ="A"; } if(checkedId==R.id.rbt_2){ Toast.makeText(Activitycharge.this,"B选中", Toast.LENGTH_LONG).show(); select ="B"; } if(checkedId==R.id.rbt_3){ Toast.makeText(Activitycharge.this,"C选中", Toast.LENGTH_LONG).show(); select ="C"; } } }); dg_button_ok.setOnClickListener(new OnClickListener() { public void onClick(View v) { if(check()==true){ if(select.equals("A")){ conneed(Integer.parseInt(amount), (Integer.parseInt(amount)+1) ); } if(select.equals("B")){ startPay(CUSTOMER_NUMBER, "CH_MOBILE",amount); } if(select.equals("C")){ startPay(CUSTOMER_NUMBER, "CH_GAME",amount); } } } }); dg_button_cancel.setOnClickListener(new OnClickListener() { public void onClick(View v) { s_Dialog.dismiss(); if(select!=null){select ="";} } }); s_Dialog.show(); }
效果图