gpt4 book ai didi

android - 执行“滚动 RecyclerView 到 : holder with view: with text:--Getting error in Android Studio”时出错

转载 作者:行者123 更新时间:2023-12-03 08:22:02 26 4
gpt4 key购买 nike

我正在使用 Recycler View 并在 Android Studio 中运行测试文件。

但是当测试文件到达此行时我收到错误

        onView(ViewMatchers.withId(R.id.itemList)).perform(RecyclerViewActions.scrollTo(withText("And a large, silver "+choice2)));

显示的错误是

androidx.test.espresso.PerformException: Error performing 'scroll RecyclerView to: holder with view: with text: is "And a large, silver CAT"' on view 'with id is cs.bham.ac.uk.wk12lh:id/itemList'.Caused by: java.lang.RuntimeException: Found 0 items matching holder with view: with text: is "And a large, silver CAT", but position -1 was requested.

请指导我做错了什么或如何做对。

最佳答案

从此改变

 onView(ViewMatchers.withId(R.id.itemList)).perform(RecyclerViewActions.scrollTo(withText("And a large, silver "+choice2)));

到此

onView(ViewMatchers.withId(R.id.itemList))
.perform(RecyclerViewActions.scrollTo(hasDescendant(withText("And a large, silver "+choice2))));

关于android - 执行“滚动 RecyclerView 到 : holder with view: with text:--Getting error in Android Studio”时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67549255/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com