2016-05-05 3 views
1

自分のラジオボタンを使用しようとしても、グループに含まれているため、一度に1つしか選択できませんが、選択肢を選択してその代わりに送信したAndroidラジオボタン

testRm.setOnClickListener(new Button.OnClickListener(
    ) { 
     @Override 
     public void onClick(View v) { 
      setReminder(); 
      displayToast("Test"); 
     } 
    }); 

setReminder方法

public void setReminder() { 
    onewk = (RadioButton) findViewById(R.id.radioButton); 
    twowk = (RadioButton) findViewById(R.id.radioButton2); 
    onemnt = (RadioButton) findViewById(R.id.radioButton3); 
    mag = (RadioButton) findViewById(R.id.radioButton4); 
    twoprt = (RadioButton) findViewById(R.id.radioButton5); 

    if(onewk.isSelected()) { 
     scheduleNotification(getNotification("1 Week"), 7); 
    } 
    if(twowk.isSelected()) { 
     scheduleNotification(getNotification("2 Weeks"), 14); 
    } 
    if(onemnt.isSelected()) { 
     scheduleNotification(getNotification("1 Month"), 30); 
    } 
    if(mag.isSelected()) { 
     scheduleNotification(getNotification("Test 1"), 30); 
    } 
    if(twoprt.isSelected()) { 
     scheduleNotification(getNotification("Test 2"), 1); 
    } 
} 

トースト方法

を:ボタンは、結果を収集し、この正しいメソッドを呼び出す提出することは、私がこれまで持っているものです

私はオンラインで見つけることができる唯一の例は、onEventメソッドでswitch文を使用しているため、他の何かを試していましたが、scheduleNotificationメソッドが呼び出されないので、悲惨に失敗しました。

答えて

2

事は、あなたがそのがcheckedまたはnot、この

onewk.isChecked()なくonewk.isSelected()

happyCodingのような意味かどうかを確認する必要があるRadioButtonためのものです。

関連する問題