Android-Espresso-滚动到非列表查看项目 [英] Android - Espresso - scrolling to a non-list View item

查看:97
本文介绍了Android-Espresso-滚动到非列表查看项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在一种通用方法来滚动到屏幕上尚不可见的非列表视图项目?

Is there a general approach for scrolling to non-list View items that are not yet visible on the screen?

在没有任何预防措施的情况下,Espresso会指示没有找到层次结构中与ID ....... p匹配的视图".

Without any precautions, Espresso will indicate that "No Views in hierarchy found matching with id .....

我找到了这个答案……这是最好的方法吗?

I found this answer ... is this the best approach?

onView( withId( R.id.button)).perform( scrollTo(), click());

推荐答案

根据View.VISIBLE" .如果是这样,那将很好用.

According to the scrollTo JavaDoc, to use the code you specified ( onView( withId( R.id.button)).perform( scrollTo(), click()); ), the preconditions are: "must be a descendant of ScrollView" and "must have visibility set to View.VISIBLE". If that is the case, then that will work just fine.

如果在AdapterView中,则应使用

If it is in an AdapterView, then you should use onData instead. In some cases, you may have to implement the AdapterViewProtocol, if your AdapterView is not well behaved.

如果它既不在AdapterView中也不在ScrollView的子级中,那么您将必须实现自定义ViewAction.

If it is neither in an AdapterView nor a child of a ScrollView, then you would have to implement a custom ViewAction.

这篇关于Android-Espresso-滚动到非列表查看项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆