使用robotium测试scrollview界面如何自动滚动底部和顶部
ScrollView scrollView_city =(ScrollView)solo.getView("id/listView_city");
int[] location=new int[2];
scrollView_city.getLocationOnScreen(location);
location[1]=location[1]+scrollView_city.getBottom();
//输出日志
Log.d("Tag","[Location x]: "+Integer.toString(location[0]));
Log.d("Tag","[Location y]: "+Integer.toString(location[1]));
if(solo.waitForView(scrollView_city)){
//从上往下滑动
int newlistcount, listcount = scrollView_city.getCount();
while(true){
solo.scrollListToLine(scrollView_city, listcount);
solo.sleep(500);
solo.drag(location[0]+10f, location[0]+10f,location[1]-10f, location[0]-100f,50);
solo.sleep(2000);
newlistcount=listView_city.getCount();
if(newlistcount==listcount){
break;
}else{
listcount=newlistcount;
Log.d("Tag","[Location]: "+Integer.toString(listcount));
}
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论