OnResume () not being called in SherlockFragment from SherlockFragmentActivity in Android?

I work in an application in which I used the Sherlock API.

I have 6 SherlockFragments to create 6 different screens. Now that my application is running, onResume is first called for all fragments.

I need a method similar to the action we use onResume to move from one fragment to another fragment. I need to call a web service method when I go from one fragment to another fragment.

I tried using onResume here, but when I go from 1st to 2nd fragment, onResume of the third fragment is called. An alternative fragment is called when we move from one fragment to the next.

Please suggest me which method should be used to call my web service when moving from 1 fragment to the next fragment.

EDITED : My actual requirement is an event that is raised when we see the Snippet for the user. At this event, I have to call the service to get updated data.

+4
source share
3 answers

. , . FragmentPagerAdapter ViewPager. TabSelection notifyDataChanged() .

:

/** Creating an instance of FragmentPagerAdapter */
final MyFragmentPagerAdapter fragmentPagerAdapter = new MyFragmentPagerAdapter(fm);

/** Setting the FragmentPagerAdapter object to the viewPager object */
_mPager.setAdapter(fragmentPagerAdapter);
_mActionBar.setDisplayShowTitleEnabled(false);

/** Defining tab listener */
ActionBar.TabListener tabListener = new ActionBar.TabListener() {

@Override
public void onTabUnselected(Tab tab, FragmentTransaction ft) {

            ft.hide(fragmentPagerAdapter.getItem(tab.getPosition()));
            fragmentPagerAdapter.notifyDataSetChanged();
            _mPager.setAdapter(fragmentPagerAdapter);
        }

        @Override
    public void onTabSelected(Tab tab, FragmentTransaction ft) {
            _mPager.setCurrentItem(tab.getPosition());

        ft.show(fragmentPagerAdapter.getItem(tab.getPosition()));
            fragmentPagerAdapter.notifyDataSetChanged();
            _mPager.setAdapter(fragmentPagerAdapter);
        }

        @Override
        public void onTabReselected(Tab tab, FragmentTransaction ft) {
        }
};
+3

onResume Activity. Fragments, Activity, onResume . , Activity, , onResume .

onAttach.

0

. onStart() onresume() sherlockfragmentactivity. notifyondatasetchanged.

0
source