Sunday 9 June 2013

Android: Event when Fragment is activated PagerTitleStrip

The problem:
I have Fragments in a PagerTitleStrip. I want to get notified when
on Fragment is activeted (i.e. get focus).

The solution: override Fragment's setUserVisibleHint() ...
public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
       
        if (this.isVisible()) {
         
        }
}

If-check is necessary because when the app (activity) is created
this method is called with isVisibleToUser equals to false...

No comments:

Post a Comment