Is there a way to remove the views from a layout recursively? The function removeAllViewsInLayout() does not seem to do the task (it removes all views from a layout, but not the layout’s children views). In my program, I add some FrameLayouts dynamically over a RelativeLayout, and over these FrameLayouts I add some ImageViews and TextViews. So I want to know if I’ll have to go make my own recursive removing-view-code or if there is some available.
Share
I think you can consider the layout as a tree. Thus, you only need a reference to the root node. If you remove it, it will be collected along with its children, since nothing else references them.
If for some reason you still see some Views after this operation, it means they belonged to a different node. You can always use the Hierarchy Viewer to “see” your UI better: http://developer.android.com/guide/developing/debugging/debugging-ui.html