3
從Java:類型推斷失敗:RecyclerViewActions.scrollTo()
onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.scrollTo(
hasDescendant(withText(artistResult.getNameVariations().get(0)))));
嘗試轉換到科特林:
onView(withId(R.id.recyclerView)).perform(RecyclerViewActions.scrollTo(
hasDescendant(withText(artistResult.nameVariations[0]))))
我得到這個堆棧跟蹤:
Error:(63, 71) Type inference failed: Not enough information to infer parameter VH in fun <VH : RecyclerView.ViewHolder!> scrollTo(itemViewMatcher: Matcher<View!>!): RecyclerViewActions.PositionableRecyclerViewAction!
Please specify it explicitly.
我不完全確定我可以明確指定「它」的位置。之前這是因爲我沒有正確初始化值,但在這裏我調用了一個方法。有任何想法嗎?