2012-07-27 102 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」值。

我希望這會幫助你更好的滾動列表視圖。 謝謝。