I have written a custom view in android. I need to do some processing when visibility of this view is changed. Is there some listener which is called when visibility of a vi
I know how to change the visibility, would like to know if there is a listener which is called when we setVisibility on the view!
you have to subclass your view/widget
and override setVisibility
, and register a interface on which you will recive the notification. For instance:
public class MyView extends View {
public interface MyListener {
public void onSetVisibilityCalled();
}
public void registerListener(MyListener myListener) {
this.mListener = myListener;
}
public void setVisibility (int visibility) {
super.setVisibility(visibility);
if (mListener != null)
mListener.onSetVisibilityCalled();
}
}