In a layout for customer registration, there are specific fields for Corporate and Individual.
The control of the type of register is done by RadioButton
that are within RadioGroup
.
I'm trying to change the RadioButton
property of the fields to Visibility
when an option is checked, but nothing is happening.
Is it possible to perform this control through gone
?
Follow code from RadioButton
RadioGroup group = (RadioGroup) findViewById(R.id.rgTipoEmpresa);
group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
boolean rbFisica = R.id.rbFisica == checkedId;
boolean rbJuridica = R.id.rbJuridica == checkedId;
if (rbFisica){
etCNPJ.setVisibility(2);
etInscricao.setVisibility(2);
tvCNPJ.setVisibility(2);
tvInscricao.setVisibility(2);
}
if (rbJuridica){
etCPF.setVisibility(2);
etRG.setVisibility(2);
tvCPF.setVisibility(2);
tvRG.setVisibility(2);
}
}
});