我想通过此文档 http://controlingquality.blogspot.in/2011/08/playing-with-android-application.html 访问 Robotium 测试类中的 ListView 子 TextView 值我看到这些行来访问 TextView
ListView lvResults = solo.getCurrentListViews().get(0);
或 ArrayList vTextViewResults = solo.getCurrentTextViews(lvResults);
第一行获取屏幕上使用的第一个列表,第二行获取 ArrayList 中的所有 TextView 控件,但缺少 .getCurrentListViews() 方法。我使用的版本 robotium:robotium-solo:5.5.2
还引用了一些链接Iterating through a List and clicking on list items in Robotium https://groups.google.com/forum/#!topic/robotium-developers/UY69TKCF5Fw
最佳答案
上网查了一下才知道,从4.0开始(不确定具体是哪个版本),有些方法被泛型方法取代了。
上一个代码,用于获取屏幕上使用的第一个列表
ListView list = solo.getCurrentListViews().get(0);
现在要在更新库中获得相同的内容,应该是
ListView list = solo.getCurrentViews(ListView.class).get(0);
因此,对于列表 TextView 中的迭代,它应该是
//TODO: Getting all TextView in the List
for (TextView txt : solo.getCurrentViews(TextView.class, solo.getCurrentViews(ListView.class).get(0))) {
Log.i("ListItem", txt.getText().toString());
}
有帮助Link
关于java - .getCurrentListViews() 方法在 Robotium 中不可用于迭代列表 TextView 。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34028325/