Espresso Recyclerview滚动到结束 [英] Espresso Recyclerview scroll to end

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

问题描述

我有一个Android应用程序,该应用程序具有带有N个元素的RecyclerView,并且当滚动时该RecyclerView到达结尾时,会添加更多元素(因此,这是一个无限列表,当滚动到达底部时将加载数据).

我想测试一下,但是我还没有找到一种方法来测试.我使用具有scrollToPosition的RecyclerViewActions,但是即使我放置了最后一个位置,也没有达到终点(因为每个元素的高度都很高).

有人知道我该怎么做吗?

解决方案

我使用下面的内容滚动到我的RecyclerView的底部.

activity = mActivityTestRule.launchActivity(startingIntent);

onView(withId(R.id.recyclerView))
                .perform(RecyclerViewActions.scrollToPosition(activity.recyclerView.getAdapter().getItemCount() - 1));

然后,您将不得不使用闲置资源(或Thread.sleep())可在加载更多数据后再次调用.

I have an Android application which has a RecyclerView with N elements, and when this RecyclerView reaches to end when scrolling, then more elements are added (so, it's an infinite list which loads data when scroll reached the bottom).

I would like to test this, but I haven't found a way to do this. I use RecyclerViewActions which have scrollToPosition but even if I put the last position, the end is not reached (because the height of each element is high).

Anybody know how could I do this?

解决方案

I use the below to scroll to the bottom of my RecyclerView.

activity = mActivityTestRule.launchActivity(startingIntent);

onView(withId(R.id.recyclerView))
                .perform(RecyclerViewActions.scrollToPosition(activity.recyclerView.getAdapter().getItemCount() - 1));

You'll then have to use idling resources (or Thread.sleep()) to call this again when more data has loaded.

这篇关于Espresso Recyclerview滚动到结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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