ViewPager를 스 와이프하고자합니다. 페이지 스 와이프에 다음 코드를 사용했습니다. 그러나 불행히도 작동하지 않습니다.Android Robotium - ViewPager 스 와이프가 작동하지 않습니다.
Solo solo = new Solo(getInstrumentation(), getActivity());
int screenHeight = activityUtils.getCurrentActivity().getWindowManager().getDefaultDisplay()
.getHeight();
int screenWidth = activityUtils.getCurrentActivity(false).getWindowManager().getDefaultDisplay()
.getWidth();
float x = screenWidth/3.0f * 2.0f;
float y = screenHeight/3.0f * 2.0f;
시도 : 1
solo.swipe(x, 0, y, y, 40);
시도 : 2
if (side == Side.LEFT)
drag(0, x, y, y, 40);
else if (side == Side.RIGHT)
drag(x, 0, y, y, 40);
시도 : 3 다음 방법 작동하지만, 그것은 단지 하나의 페이지를 움직이는하고 또한 움직이는 매우 느리게.
solo1.scrollToSide(Solo.RIGHT);
빠른 스 와이프 옵션이 있습니까? 어느 것이 가장 좋습니까? 친절하게 당신의 아이디어를 공유하십시오.
Robotium 나의 코드가 5.1보기 호출기에 대한
for (int count = 0; count < noOfPages; count++)
solo.swipeToRight(count);
방법이
private void swipeToLeft(int stepCount) {
Display display = solo.getCurrentActivity().getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
float xStart = width - 10 ;
float xEnd = 10;
solo.drag(xStart, xEnd, height/2, height/2, stepCount);
}
private void swipeToRight(int stepCount) {
Display display = solo.getCurrentActivity().getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
float xStart = 10 ;
float xEnd = width - 10;
solo.drag(xStart, xEnd, height/2, height/2, stepCount);
}
Robotium 5.1을 다운로드했지만 여전히 문제가 있습니다. – vinoth
이것을 사용해보십시오 : solo.scrollViewToSide (solo.getView ("viewPager"), Solo.RIGHT); – Renas