Godfryd Godfryd - 10 months ago 142
Android Question

setVisibility(View.Visible) not working after setting to invisible

part is working fine, but when I press the radio button to bring back the visibility the items are not appearing. What am I missing?

rg = (RadioGroup) myView.findViewById(R.id.radioGroup);

rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId){
case R.id.list:{


case R.id.order:{




Answer Source

Since you use a switch, you need to be carefull about when to stop.

You need to tell when to stop to read, each following case would be execute until you reach a break.

Here :

switch (checkedId){
    case R.id.list:
        break; // *** LINE A
    case R.id.order:

Without LINE A, the following lines will be executed too, meaning you will set the view to VISIBLE then INVISIBLE on one call.