问题
I have created a test project for my Android project. In my app there is a listview that has a lot of data. I need to scroll this listview up and down using Robotium. I have used the scrollUp()
and scrollDown()
functions, but it is scrolling too slowly.
I am using Robotium 3.3. Is there any way to make a fast scroll?
回答1:
int screenWidth = getActivity().getWindowManager().getDefaultDisplay().getWidth();
int screenHeight = getActivity().getWindowManager().getDefaultDisplay().getHeight();
int fromX, toX, fromY, toY = 0,stepCount=1;
// Scroll Down // Drag Up
fromX = screenWidth/2;
toX = screenWidth/2;
fromY = (screenHeight/2) + (screenHeight/3);
toY = (screenHeight/2) - (screenHeight/3);
solo.drag(fromX, toX, fromY, toY, stepCount);
here
[1] stepCount=1; // very fast scroll
[2] stepCount=10; // medium scroll
[3] stepCount=17; // slow scroll
So you adjust " stepCount " value according to your scroll required speed.
i hope this will help you for your better scroll list view. Thanks.
来源:https://stackoverflow.com/questions/11682196/fast-scroll-in-robotium