2012-07-27 91 views
1

我为我的Android项目创建了一个测试项目。在我的应用程序中有一个有很多数据的列表视图。我需要使用Robotium上下滚动这个列表视图。我已经使用了scrollUp()scrollDown()函数,但它滚动速度太慢。Robotium中的快速滚动

我正在使用Robotium 3.3。有什么方法可以快速滚动吗?

回答

4
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); 

这里

[1] STEPCOUNT = 1; //非常快的滚动

[2] stepCount = 10; // medium scroll

[3] stepCount = 17; //慢滚动

因此,您根据您的滚动所需速度调整“stepCount”值。

我希望这会帮助你更好的滚动列表视图。 谢谢。