0

I had gone through this and found a common answer i.e

        int selectedId = radioGroup.getCheckedRadioButtonId();

        radioButton = (RadioButton) findViewById(selectedId);

        Toast.makeText(MyAndroidAppActivity.this,
            radioButton.getText(), Toast.LENGTH_SHORT).show();

But how to get text using view binding?

1 Answers1

1

You could do this:

EDIT:

int id = binding.radioGroup.getCheckedRadioButtonId();
RadioButton radioButton = binding.getRoot().findViewById(id);
//Then get the radio button's text
Toast.makeText(MyAndroidAppActivity.this,
        radioButton.getText(), Toast.LENGTH_SHORT).show();
AzureStar123
  • 106
  • 6