解决方法
RadioGroup radioGroup; RadioButton radioButton1; RadioButton radioButton2; RadioButton radioButton3; boolean hack = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); radioGroup = (RadioGroup) findViewById(R.id.rg); radioButton1 = (RadioButton) findViewById(R.id.r1); radioButton2 = (RadioButton) findViewById(R.id.r2); radioButton3 = (RadioButton) findViewById(R.id.r3); OnClickListener radioClickListener = new OnClickListener() { public void onClick(View v) { if (v.getId() == radioGroup.getCheckedRadioButtonId() && hack) { radioGroup.clearCheck(); } else { hack = true; } } }; OnCheckedchangelistener radioCheckchangelistener = new OnCheckedchangelistener() { @Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { hack = false; } }; radioButton1.setonCheckedchangelistener(radioCheckchangelistener); radioButton2.setonCheckedchangelistener(radioCheckchangelistener); radioButton3.setonCheckedchangelistener(radioCheckchangelistener); radioButton1.setonClickListener(radioClickListener); radioButton2.setonClickListener(radioClickListener); radioButton3.setonClickListener(radioClickListener); }
好的,现在我已经更新了.这应该是Philipz