2

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:

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;
            case 4:
                tabLayout = R.layout.tab5;                  
                break;

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



        if(position==2)
        {
            InitialTab3(rootView);
            new GetTopNotifications(rootView);
        }


        return rootView;
    }
}
bebosh
  • 806
  • 10
  • 25

0 Answers0