I have two RadioButton
s inside a RadioGroup
. I want to set OnClickListener
on those RadioButton
s. Depending on which RadioButton
is clicked, I want to change the text of an EditText
. How can I achieve this?
I'd think a better way is to use RadioGroup
and set the listener on this to change and update the View
accordingly (saves you having 2 or 3 or 4 etc listeners).
RadioGroup radioGroup = (RadioGroup) findViewById(R.id.yourRadioGroup);
radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// checkedId is the RadioButton selected
}
});