Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to destroy a custom view

Tags:

android

So I have a custom view I'm implementing, and would like to know how to destroy it when it is clicked. I've tried using onClickListeners, implemented both in and outside of the activity, I've tried calling invalidate() to no avail. At this point I'm stuck with an empty onTouchEvent method and no clue of how to destroy the view when it is clicked.

P.S. By destroy I mean make it disappear from the UI thread.

like image 488
Bill L Avatar asked May 01 '14 02:05

Bill L


1 Answers

You can remove the view from its parent Layout to make it disappear/destroy like this

 parentLayout.removeView(customView);

Or , You can hide the View to disappear and show it back later if required

 customView.setVisibility(View.GONE);
like image 160
Libin Avatar answered Nov 05 '22 05:11

Libin