Posts

Showing posts with the label Visibility

Conditional Display Of Html Element Forms

Answer : What worked: You had two buttons, both visible in the beginning. And on click of one button, you hid a div , and made another visible. Now you need a situation when the divs should be hidden in the beginning, and then show when you click a button. By default, for all elements where a explicit visibility attribute is not given, visibility is considered to be visible . To make the button invisible, you need to add visibility:hidden to the button. You can do it two ways: In the code for the div s, make then "invisible by default" by adding style='visibility:hidden' . Add another javascript function that is called on load of the page, and makes both the divs invisible: function hideBoth() { document.getElementById("cont1").style.visibility="hidden"; document.getElementById("cont2").style.visibility="hidden"; } Call it on load of your page: <body onload='hideBoth()'> This line: document.get...

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.