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.
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);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With