I am using PagerSlidingTabStrip
in my project and am showing data in fragments. Its a great library which works great. Each Fragment consists of a scholar\'s le
private boolean isLoaded =false,isVisibleToUser;
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
this.isVisibleToUser=isVisibleToUser;
if(isVisibleToUser && isAdded() ){
loadData();
isLoaded =true;
}
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
if(isVisibleToUser && (!isLoaded)){
loadData();
isLoaded=true;
}
}
You could override setUserVisibleHint
event of the fragment to know if its visible to the user and then load your data. something like following:
boolean _areLecturesLoaded = false;
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser && !_areLecturesLoaded ) {
loadLectures();
_areLecturesLoaded = true;
}
}