views:

1763

answers:

2

Is there a way I can programatically perform a Fling on a listview? I know there is monkey that does all these things but that requires a computer connection with adb etc etc. I want to do it with my app on any phone, without monkey.

Thanks, Faisal

A: 

Hello,

You can fake it with an anim (i think accelerate_decelerate_interpolator can do the job).

Also it seems there is support for scrolling your view by your own:

public void scrollBy (int x, int y)

Move the scrolled position of your view. This will cause a call to onScrollChanged(int, int, int, int) and the view will be invalidated.

Parameters
x   the amount of pixels to scroll by horizontally
y   the amount of pixels to scroll by vertically
public void scrollTo (int x, int y)

Set the scrolled position of your view. This will cause a call to onScrollChanged(int, int, int, int) and the view will be invalidated.

Parameters
x   the x position to scroll to
y   the y position to scroll to
Lucas S.
Hey Lucas, do you have a code snippet, I'm pretty confused.Thanks,Faisal
Faisal Abid
Hello, i added more info that will help you.
Lucas S.
Thanks man i didnt know of this!
Faisal Abid
A: 

There are two methods to "smooth scroll" rather than jump to a position.

Check out http://developer.android.com/reference/android/widget/ScrollView.html

for smoothScrollBy() and smoothScrollTo().

Hope this helps.

Matt