Android SetVisibility Does Not Display If Initially Set To Invisble
Answer :
Had similar error but it was due to my silly mistake of not using the UiThread.
Activity act = (Activity)context; act.runOnUiThread(new Runnable(){ @Override public void run() {     mLayoutLights.setVisibility(View.VISIBLE);   } }); Got it. You have to set the visibility of all the items in the layout, not just the layout. So this code worked:
if (mLayoutLights.getVisibility() == View.VISIBLE) {     ((Button) findViewById(R.id.btnLightsOK)).setVisibility(View.GONE); ((Button) findViewById(R.id.btnLightsCnc)).setVisibility(View.GONE); mLayoutLights.setVisibility(View.GONE); } else {     mLayoutLights.setVisibility(View.VISIBLE); ((Button) findViewById(R.id.btnLightsOK)).setVisibility(View.VISIBLE); ((Button) findViewById(R.id.btnLightsCnc)).setVisibility(View.VISIBLE); } In my case, with a plain SurfaceView, I just set the View to GONE in xml, not INVISIBLE. Then I can set VISIBILITY correctly after that.
Comments
Post a Comment