Reputation: 16298
How do I remove a View from its superview? In iOS it's performed by sending removeFromSuperview
to the view that should be removed.
Upvotes: 16
Views: 5050
Reputation: 67502
You can use getParent()
to get the parent of the View
, then call removeView()
on it.
View yourView = ...;
ViewGroup viewParent = (ViewGroup) yourView.getParent();
viewParent.removeView(yourView);
Upvotes: 31