1
I would like to know how to make the event change of a spinner it leaves visible or invisible a radiobutton. I have the following code. But it’s not working.
<RadioGroup
android:id="@+id/radioGrupo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radioUsuario"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:onClick="onRadioButtonClicked"
android:text="Usuário" />
<RadioButton
android:id="@+id/radioNaoUsuario"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:visibility="invisible"
android:text="Não usuário" />
</RadioGroup>
private void ExibeUsuarioNaoUsuario()
{
naoUsuario =(RadioButton) findViewById(R.id.radioNaoUsuario);
usuario =(RadioButton) findViewById(R.id.radioUsuario);
groupUsuarioNaoUsuario =(RadioGroup)findViewById(R.id.radioGrupo);
spnTipoCliente = (Spinner)findViewById(R.id.spnTipoCliente);
spnTipoCliente.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long id) {
groupUsuarioNaoUsuario.setVisibility(RadioGroup.VISIBLE);
//usuario.setVisibility(RadioButton.VISIBLE);
//naoUsuario.setVisibility(RadioButton.VISIBLE);
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
usuario.setVisibility(RadioButton.INVISIBLE);
naoUsuario.setVisibility(RadioButton.INVISIBLE);
}
});
}
How do you know the code doesn’t work? Are you sure that the
onItemSelected
isn’t being called? Or are the buttons not invisible? Hiding theRadioGroup
and theRadioButton
doesn’t work?– Wakim
@Wakim tried to make invisible only the radiogroup or only the radiobuttons but it did not work. When I change the spinner item it does not make them visibel even I passing the setvisibilty. And this being called yes certainly.
– Rabelos
I’ll test your code here and see if I can reproduce the problem.
– Wakim