Disposing of controls in a layout at runtime on an

2019-06-11 07:17发布

问题:

I need to reset a layout or dispose some of the controls on that layout according to some certain cases. But I couldn't find a way to do so. Do you have an idea about how to do?

Thanks in advance.

回答1:

Maybe you can just the hide the components, e.g. findViewById(R.id.the_id_of_the_view_to_hide).setVisibility(View.GONE);

There are different parameters for the visibility. GONE hides the view and also frees up the space, the view used before, as if it was removed completely.