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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:07:05+00:00 2026-05-14T00:07:05+00:00

in iPhone, this would be simple—each view has a scrollViewDidScroll method. I am trying

  • 0

in iPhone, this would be simple—each view has a scrollViewDidScroll method. I am trying to find the equivalent in Android.

My code works, but it isn’t giving me what I want. I need to execute code the entire duration that a view is scrolling. So, even though I use OnGestureListener’s onScroll method, it only fires when the finger is on the screen (it’s not really named correctly—it should be called “onSlide” or “onSwipe”, focusing on the gesture rather than the UI animation). It does not continue to fire if the user flicks the view and it is still scrolling for a few moments after the user lifts his finger.

is there a method that is called at every step of the scroll?

public class Scroll extends Activity implements OnGestureListener {

public  WebView         webview;

public  GestureDetector gestureScanner;

public  int         currentYPosition;
public  int         lastYPosition;

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    webview = new WebView(this);
    setContentView(webview);
    webview.loadUrl("file:///android_asset/Scroll.html");

    gestureScanner = new GestureDetector(this);

    currentYPosition = 0;
    lastYPosition = 0;

}


public boolean onTouchEvent(final MotionEvent me) {
    return gestureScanner.onTouchEvent(me);
}


public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
    // I do stuff here.
    return true;
}
  • 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-14T00:07:05+00:00Added an answer on May 14, 2026 at 12:07 am

    I’ve played around a little bit with a WebView and didn’t find a way to track the scrolling, but do you definitely need it to be a WebView? If you’re using a ListView or a GridView, you can implement the ListView.OnScrollListener methods, notably onScrollStateChanged and onScroll. The former is particularly useful as it gives you updates on what the list is doing, even for your specific example of the user ‘flinging’ the list and it continues to scroll for some time afterwards. An example of how you would track that:

    public class List13 extends ListActivity implements ListView.OnScrollListener {
    
    (...)
    
        public void onScrollStateChanged(AbsListView view, int scrollState) {
            switch (scrollState) {
            case OnScrollListener.SCROLL_STATE_IDLE:
                //List is idle
                break;
            case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
                //List is scrolling under the direct touch of the user
                break;
            case OnScrollListener.SCROLL_STATE_FLING:
                //The user did a 'fling' on the list and it's still scrolling
                break;
            }
        }
    }
    

    I lifted that straight out of the code samples Google provides, example List13 in the “Api Demos” project. If you want to have a closer look at that, import it into Eclipse by going to File -> New -> Android Project, Create Project from Existing Source, and navigate to (your SDK folder)/platforms/(the version you’re working with)/samples/ApiDemos. If you can’t find it, you might not have downloaded the sample apps when you set up your SDK. You can do that in Eclipse by going to Window -> Android SDK and AVD Manager, then under “Available Packages” on the left.

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

Sidebar

Ask A Question

Stats

  • Questions 443k
  • Answers 444k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Start with these previous answers on SO: Getting started with… May 15, 2026 at 6:25 pm
  • Editorial Team
    Editorial Team added an answer Have you tried the keypress event? The keypress event is… May 15, 2026 at 6:25 pm
  • Editorial Team
    Editorial Team added an answer Well I think there are a few options to improve… May 15, 2026 at 6:25 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.