shakatreh87
Lurker
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]
* 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]