How to check if "Radiobutton" is checked?

Ricardo Potozky de Oliveira picture Ricardo Potozky de Oliveira · Jun 15, 2012 · Viewed 175.7k times · Source

I would like to make a structure with the condition (if-else) RadioButton

I want that when the Radiobutton RB1 is selected, this function is active:

regAuxiliar = ultimoRegistro;

And when the radiobutton RB2 is selected, this function is active:

regAuxiliar = objRegistro;

And sorry for my English, I'm Brazilian.

Answer

FabianCook picture FabianCook · Jun 15, 2012

Just as you would with a CheckBox

RadioButton rb;

rb = (RadioButton) findViewById(R.id.rb);

rb.isChecked();