Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make a Compound Control remove itself from parent Layout

I created a Compound Control that is added at runtime from an activity, but will need to be removed when a button is clicked from within the control.

How do I send a message to the parent LinearLayout and tell it to remove the control? (Or tell it to remove itself - if that's even possible) If possible I'd like a method to do this from within the control itself.

Thanks.

like image 608
bwoogie Avatar asked Dec 10 '22 06:12

bwoogie


1 Answers

Save reference of your control after creating, and use ViewGroup.removeView method when it is necessary.

If you need to do it from control itself, invoke ((ViewGroup)getParent()).removeView(this) from within the control.

like image 85
Andrei Buneyeu Avatar answered Dec 29 '22 12:12

Andrei Buneyeu