I have an activation tab and three framgents in it: Activation code: the method is called naturally in the crate:

private void init_slider() { // Creating The Toolbar and setting it as the Toolbar for the activity toolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(toolbar); // Creating The ViewPagerAdapter and Passing Fragment Manager, Titles fot the Tabs and Number Of Tabs. adapter = new TabsActionAdapter(getSupportFragmentManager(), Titles, Numboftabs); // Assigning ViewPager View and setting the adapter pager = (ViewPager) findViewById(R.id.pager); pager.setAdapter(adapter); // Assiging the Sliding Tab Layout View tabs = (SlidingTabLayout) findViewById(R.id.tabs); tabs.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { } @Override public void onPageScrollStateChanged(int state) { initializeData(); *****Log.w("Initialize Data:","Download initialized");****** } }); tabs.setDistributeEvenly(true); // To make the Tabs Fixed set this true, This makes the tabs Space Evenly in Available width // Setting Custom Color for the Scroll bar indicator of the Tab View tabs.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() { @Override public int getIndicatorColor(int position) { return getResources().getColor(R.color.tabsScrollColor); } }); // Setting the ViewPager For the SlidingTabsLayout tabs.setViewPager(pager); } 

Pay attention to the line marked * *

and now logs:

 06-17 10:50:33.485 21936-21936/eatgid.com.restaurant W/Initialize Data: Download initialized 06-17 10:50:33.510 21936-21936/eatgid.com.restaurant W/Initialize Data:: Download initialized 06-17 10:50:33.759 21936-21936/eatgid.com.restaurant W/Initialize Data:: Download initialized 

This is one swipe or click !!! I'm not saying that the onPageScrolled lisenera method is called 10 times with one svaype! where to dig?

and backfilling on the same topic with tabs, I’m not strong in them yet, but I’m frightened by the inscription in the log when svaype:

 06-17 10:50:33.762 21936-21936/eatgid.com.restaurant W/FragmentManager: moveToState: Fragment state for Tab3{ffc7800 #2 id=0x7f0c0054 android:switcher:2131492948:2} not updated inline; expected state 3 found 2 

Does this mean that I have a jamb somewhere in the code?

    1 answer 1

    Because in the process of changing the page, the state of the scroll changes 3 times, everything is simple.

    1. Page scrolled ( SCROLL_STATE_IDLE )
    2. The page is brought to the final state after the user scrolls ( SCROLL_STATE_SETTLING )
    3. Page is scrolled by user ( SCROLL_STATE_DRAGGING )

    You can see what state you are responsible for here.

    • is ingenious? thank you very much for your response! worth doing if(state==ViewPager.SCROLL_STATE_SETTLING) { initializeData(); Log.w("Initialize Data:", "Download initialized"); } and everything went as it should! is called once - Julian Del Campo
    • Could you also suggest why the following message appears? FragmentManager: moveToState: Fragment state for Tab3{ffc7800 #2 id=0x7f0c0054 android:switcher:2131492948:2} not updated inline; expected state 3 found 2 FragmentManager: moveToState: Fragment state for Tab3{ffc7800 #2 id=0x7f0c0054 android:switcher:2131492948:2} not updated inline; expected state 3 found 2 - Julian Del Campo
    • @JulianDelCampo, does this message cause any problems? - Vladyslav Matviienko
    • it seems that it doesn’t cause visible problems at all, but it’s just a premonition that something seems to be wrong ... I usually take application logs very seriously, and even some ordinary things like Err (0) Log Buff or Service: ActiveConnections ... mazol eyes, worse, these messages are not googled for yet - Julian Del Campo