Android Robolectric Click RecyclerView Item
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is there any way to simulate a click on a RecyclerView item with Robolectric? So far, I have tried getting the View at the first visible position of the RecyclerView , but that is always null . It's getChildCount() keeps returning 0 , and findViewHolderForPosition is always null . The adapter returns a non-0 number from getItemCount() (there are definitely items in the adapter). I'm using Robolectric 2.4 SNAPSHOT. 回答1: Seems like the issue was that RecyclerView needs to be measured and layed out manually in Robolectric. Calling this solves