Godfryd Godfryd - 1 year ago 190
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download