2012-07-14 107 views
2

我與four無線電buttons.The問題的應用程序是最後一個單選按鈕是不可點擊開始,直到你點擊一些其他button.After點擊其他一些單選按鈕,最後一個單選按鈕變爲clickable.plz告訴我如何解決這個問題。提前感謝。單選按鈕無法點擊

private void uncheckAllOptions() 
    { 
     myOption1.setChecked(true); 
     myOption2.setChecked(true); 
     myOption3.setChecked(true); 
     myOption4.setChecked(true); 

     myOption1.setChecked(false); 
     myOption2.setChecked(false); 
     myOption3.setChecked(false); 
     myOption4.setChecked(false); 

} 

我使用這段代碼保存單選按鈕的狀態,但最後一個單選按鈕始終保持不可點擊,直到並且除非第3中的單選按鈕中的一個被點擊

+3

發佈一些代碼,請 – AMerle 2012-07-14 09:14:00

+0

離不開代碼幫助。添加代碼。 – Hardik4560 2012-07-14 09:20:07

+0

發佈的代碼請立即幫 – 2012-07-14 09:29:35

回答

5

使用clearCheck() function of RadioButtonGroup to clear all RadioButtons

使用myOption4.setChecked(false);不能檢查下一次,直到您檢查另一個RadioButton。

一樣,radioButtonGroup.clearCheck();

+0

但爵士這是行不通的 – 2012-07-14 09:29:06

+0

@ user1522540,它的工作對我來說,你用'的RadioButtonGroup?',看到我的答案鏈接... – 2012-07-14 09:32:38

0

所有的先放以XML託點擊=假的單選按鈕,4:

那麼假設你想,如果點擊單選按鈕點擊FIRST RadioButton後,在偵聽器中設置RB-4 clickable = True。

如下圖:

rb1.setOnCheckedChangeListener(new OnCheckedChangeListener() { 
      @Override 
      public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 
       if(isChecked) 
        rb4.setClickable(true); 
      } 
     }); 
+0

準確,你想做些什麼?告訴我一些細節。 – 2012-07-14 09:56:48

+1

謝謝先生問題解決了,謝謝你的幫助 – 2012-07-14 10:46:34

+0

你是怎麼做到的?告訴我,你也增加了我的知識。 – 2012-07-14 10:48:10