Apps Delay showing content in Fragment Pager Adapter

I'm using FragmentPagerAdapter has 5 tabs. In tab number 3 I'm showing data in listview from web service and it showing successfully. When I swipe to tab 2, 4 and return to tab 3, the data is still showing in listview. If I swipe to tab 1, 5 and return to tab 3, the data delay to appearing some seconds.
* In TabFragment class I'm calling AsyncTask class called "GetTopNotifications". like this coding:
[HIGH]
public static class TabFragment extends Fragment
{
public static final String ARG_OBJECT = "object";

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
Bundle args = getArguments();
int position = args.getInt(ARG_OBJECT);

int tabLayout = 0;
switch (position)
{
case 0:
tabLayout = R.layout.tab1;
break;
case 1:
tabLayout = R.layout.tab2;
break;
case 2:
tabLayout = R.layout.tab3;
break;
case 3:
tabLayout = R.layout.tab4;
break;

}
View rootView = inflater.inflate(tabLayout, container, false);



if(position==0)
InitialTab1(rootView);
if(position==1)
InitialTab2(rootView);
if(position==2)
{
InitialTab3(rootView);
new GetTopNotifications(rootView);
}
if(position==3)
{
InitialTab4(rootView);
new GetTopMessages(rootView);
}



return rootView;
}
}[/HIGH]
 

Unforgiven

...eschew obfuscation...
Administrator
Welcome to Android Forums shakatreh87.

I moved this to the application development forum to get some better eyes on it.:)
 

out of ideas

Android Enthusiast
the fragment remains the same for a little while before it has to get recreated, so when you do 2,4,3 it never really let go of 3.

when you do the other one, it has to start over and repopulate(like if you rotate your screen or leave your app)
 
Top