使用 Espresso 检查 ListView 中元素的内容

Check content of an element inside a ListView with Espresso

如何检查 ListView 中某个项目的信息是否正确显示。

我需要检查 TODO Title Sample 这是一个 TextView 和 TODO Location Sample 这也是一个 TextView 是否正确显示使用 Espresso 发短信。我有以下代码,但它不起作用:

onData(anything()).inAdapterView(withId(R.id.to_do_list_view)).atPosition(0).
               check(matches(withChild(withId(R.id.item_title)).matches(withText("TODO Title Sample"))));

知道我该如何解决吗?

我想出来了,而且很简单:

onData(anything()).inAdapterView(withId(R.id.to_do_list_view)).atPosition(0).
               onChildView(withId(R.id.item_title)).
               check(matches(withText("TODO Title Sample")));