Search code examples
androidimageviewandroid-relativelayout

clearing contents of a RelativeLayout programmatically - android java


I am dynamically adding ImageViews to a RelativeLayout depending on user input. I have also created a button that when pressed, should clear all of the content of that RelativeLayout (remove all children). I was hoping for a .clear() method, but no such luck.

can someone point me in the right direction here?

RelativeLayout rel = (RelativeLayout) findViewById(R.id.iv_section);
rel.SomethingToRemoveAllChildren();

thanks.


Solution

  • ViewGroup.removeAllViews()