在我的應用程序,我創建單選按鈕動態,並希望取消選中其中一個選中時的所有其他單選按鈕。爲此目的,我使用RadioGroup .clearCheck(),但它不是在all.This工作是代碼:RadioGroup.clearCheck()不工作的情況下動態創建的單選按鈕
for (int i=0; i<files.length; i++)
{
rbi = new RadioButton(context);
rb1 = new RadioGroup(context);
rb1.addView(rbi);
nameOfFile = files[i].getName();
rbi.setText(nameOfFile);
ll.addView(rb1);
rbi.setOnClickListener(
new RadioButton.OnClickListener()
{
@Override
public void onClick(View v)
{
rb1.clearCheck();
rbi.setChecked(true);
}
請幫me.Even的替代解決方案爲實現這一目標將提前welcomed.Thanks。
請幫幫我。 – user1726619
他們都檢查時檢查一個? – Bigflow
你是AFAIK不應該爲'RadioButton'做'setOnClickListener'因爲'RadioGroup'已經通過'setOnCheckedChangeListener'來管理它了。 – zapl