I have a SurfaceView with a LinearLayout which hides or shows if you click on the SurfaceView. The problem is that the SurfaceView is not refreshed so if the setVisibility(View.VISIBLE) actually doesn't work.
This is the code I'm using:
sv.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
Log.d("MainActivity-onCreate-onClick-buttons",
buttonsVisibility.toString());
if (buttonsVisibility)
{
linearLayoutButtons.setVisibility(View.INVISIBLE);
buttonsVisibility = false;
} else
{
linearLayoutButtons.setVisibility(View.VISIBLE);
buttonsVisibility = true;
}
}
});
By default buttonVisibility is set to false and the first time I click the view it actually is so so the logic is consistent, the only problem is that the setVisibility seems to have no effect. Only if I turn on/off the screen I can see the layout displayed correctly and then working properly. Why I need to turn the screen off to refresh the UI? Shouldn't it refresh automatically after the setVisibility?
Thank you very much