Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6905095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:08:31+00:00 2026-05-27T08:08:31+00:00

Jon Willis has posted on how to enable an infinite scrolling with his code.

  • 0

Jon Willis has posted on how to enable an infinite scrolling with his code.

In there he said that he made some changes in the ViewPager class in the android support library. Which changes have been made and how is it possible to "recompile" the library with the ViewPager change?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:08:32+00:00Added an answer on May 27, 2026 at 8:08 am

    Thank you for your answer Shereef.

    I solved it a little bit differently.

    I changed the code of the ViewPager class of the android support library. The method setCurrentItem(int)

    changes the page with animation. This method calls an internal method that requires the index and a flag enabling smooth scrolling. This flag is boolean smoothScroll.
    Extending this method with a second parameter boolean smoothScroll solved it for me.
    Calling this method setCurrentItem(int index, boolean smoothScroll) allowed me to make it scroll indefinitely.

    Here is a full example:

    Please consider that only the center page is shown.
    Moreover did I store the pages seperately, allowing me to handle them with more ease.

    private class Page {
      View page;
      List<..> data;
    }
    // page for predecessor, current, and successor
    Page[] pages = new Page[3];
    
    
    
    
    mDayPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
    
            @Override
            public void onPageSelected(int position) {
            }
    
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}
    
            @Override
            public void onPageScrollStateChanged(int state) {
    
                if (state == ViewPager.SCROLL_STATE_IDLE) {
    
                    if (mFocusedPage == 0) {
                        // move some stuff from the 
                                                // center to the right here
                        moveStuff(pages[1], pages[2]);
    
                        // move stuff from the left to the center 
                        moveStuff(pages[0], pages[1]);
                        // retrieve new stuff and insert it to the left page
                        insertStuff(pages[0]);
                    }
                    else if (mFocusedPage == 2) {
    
    
                        // move stuff from the center to the left page
                        moveStuff(pages[1], pages[0]); 
                        // move stuff from the right to the center page
                        moveStuff(pages[2], pages[1]); 
                        // retrieve stuff and insert it to the right page
                                                insertStuff(pages[2]);
                    }
    
                    // go back to the center allowing to scroll indefinitely
                    mDayPager.setCurrentItem(1, false);
                }
            }
        });
    

    However, without Jon Willis Code I wouldn’t have solved it myself.

    EDIT: here is a blogpost about this:

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On Jon's site he has thisvery elegantly designed singleton in C# that looks like
I have the following code (thanks to input from 'jon Z' and 'manojlds') that
Jon Skeet posted this blog post , in which he states that he is
Jon Skeet made a comment (via Twitter) on my SOApiDotNet code (a .NET library
I have pasted some code from Jon Skeet's C# In Depth site: static void
In this post Jon Skeet pointed out that the following code should be changed
Jon Skeet said that and String.Empty are equivalent due to string interning. In looking
This question is inspired by Jon Skeet's answer: Is there a c# equivalent to
We're using Jon Skeet's proto-csharp-port, and I'm running into some difficulties when mixing it
Jon Skeet has the following reputation tracker which is built by C#. I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.