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 8030349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:44:15+00:00 2026-06-05T00:44:15+00:00

I have a problem with pageviewer. I want to my page scroll every two

  • 0

I have a problem with pageviewer. I want to my page scroll every two seconds. I try something like this:

handler.postDelayed(new Runnable() {
    public void run() {

        viewPager.setCurrentItem(viewPager.getCurrentItem()+1, true);

    } 
},2000);

But it works only when I start activity. If i put this code to public void onPageSelected(int page) it works but I want to do when I click and manually scroll page I want to stop this handler but it doeasn’t work. How I can do that?

  • 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-06-05T00:44:17+00:00Added an answer on June 5, 2026 at 12:44 am

    You should define your Runnable and Handler like this:

    private boolean pagerMoved = false;
    private static final long ANIM_VIEWPAGER_DELAY = 2000;
    
    private Handler h = new Handler();
        private Runnable animateViewPager = new Runnable() {
            public void run() {
                if (!pagerMoved) {
                    viewPager.setCurrentItem(viewPager.getCurrentItem()+1, true);
                    h.postDelayed(animationFrame, ANIM_VIEWPAGER_DELAY);
                }
            }
        };
    

    Make sure that you setup and tear down in your onPause & onResume methods

    @Override
        public void onPause() {
            super.onPause();
            if (h != null) {
                h.removeCallbacks(animateViewPager);
            }
        }
    
        @Override
        public void onResume() {
            super.onResume();
            h.postDelayed(animateViewPager, ANIM_VIEWPAGER_DELAY);
        }
    

    Finally, you’ll need to listen for a touch event on your viewpager so that you can set pagerMoved to true (which will then stop further automatic page transitions).

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

Sidebar

Related Questions

I have problem like this https://dev.twitter.com/discussions/4563 if (webResponse.Headers[Content-Encoding] == gzip) { byte[] bytes =
I have problem with this code..I want to extract data from flat file and
I got this an asp.net 3.5 page that and I have few tabs (telerik
I have problem when I try to set a background to .header - nothing
i have problem with jquery submit and post. I would like to submit a
Have problem while getting data from Memcached on .NET MVC solution. I have this
I have problem with encoding data in Oracle database. I want to xor string
I have problem with customizing each page using pagecontrol and UIScrollView. I'm customizing Page
I have problem calling a JavaScript function in an iframe from the parent page.
I'd like to have better error page reporting in Google Analytics. Currently, if someone

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.