In the ViewPager+Fragment by FragmentPagerAdapter mode. I want to known How to load data for Internet.
I want to implement:
1.Only select the current pager can to load data
2.Only performing the load data once to every pager
I search the some Answers: userd the callBack method,I see the lifecyle. It Callback after onCreate. After that dont callBack. if load data so fast . onCreateVie and onActivityCreate don't callBack. View not find. so this method not improper.
boolean isFist
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if(isFist&&isVisibleToUser){
// int this load data
}
}
so,who can give me good Solutions? Please Forgive my broken English.
This example, shows how to use AsyncTask:
So:
Note: Right now I do not have time to put this example in the context of your specific question, but AsyncTask is your best option.
EXAMPLE: