0

I have a button called panel_close in my java code. In the setOnclickListener method I update the visibility of some other views. However, it seems sometimes the code does not update the visibility of the panels properly. Here is the code

panel_close.setOnClickListener(new OnClickListener() {


        @Override
        public void onClick(View v) {
            View temp=findViewById(R.id.show_panel);
            temp.startAnimation(window_close);
            temp.setVisibility(View.GONE);
            compass.setVisibility(View.VISIBLE); // compass is defined as a field. Sometimes the code does not make this view visible
            stats.setVisibility(View.VISIBLE); // stats is defined as a field. Sometimes the code does not make this view visible
            control.setVisibility(View.VISIBLE); // control is defined as a field. Sometimes the code does not make this view visible


            loadAllList(); // this is an AsyncTask
            loadAllpins(); // this is an AsyncTask

        }
    });

Any comment will be appreciated.

vmontazeri
  • 393
  • 2
  • 20

2 Answers2

0

You should look at running these changes on the UI thread to make sure that the modification are visible to the UI:

Android - using runOnUiThread to do UI changes from a thread

Community
  • 1
  • 1
StephenG
  • 2,851
  • 1
  • 16
  • 36
0

You should give a detailed info about your variables first and this could be happening because you are making the layout or something like that invisible or gone, which the children are inside of. This will cause them to remain invisible.