0
In a layout for client registration, there are the specific fields for Legal Entities and Individuals.
Control of the type of registration is done by RadioButton
who are inside a RadioGroup
.
I needed that when selecting the RadioButton
of a Natural Person, the fields relating to a Legal Person are not visible on the screen and vice versa.
I’m trying to change the property Visibility
from the fields to gone
when an option is checked, but nothing is happening.
It is possible to carry out this control through the RadioButton
?
Follows code from RadioGroup
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);
}
}
});
Perfect. I ended up confusing the
setVisibility
with theandroid:visibility
.– emanuelsn