Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing a View from an Activity

Tags:

You've got a View defined in a layout file. How do you remove it from you Activity code?

like image 756
Emanuil Rusev Avatar asked Jun 20 '10 19:06

Emanuil Rusev


1 Answers

ViewGroup vg = (ViewGroup)(myView.getParent());
vg.removeView(myView);

should do what you want as far as correctly removing the View from the Activity. The other guys' answer will just make the View invisible, using up resources.

like image 188
Matt Avatar answered Oct 05 '22 00:10

Matt