bwoogie
bwoogie

Reputation: 4427

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.

Upvotes: 4

Views: 1669

Answers (1)

Andrei Buneyeu
Andrei Buneyeu

Reputation: 6680

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.

Upvotes: 14

Related Questions