.getCurrentListViews() 方法在 Robotium 中不可用于遍历列表文本视图。
.getCurrentListViews() method is not available in Robotium for Iterating through list textview.
我想在 Robotium 测试 class 中访问列表视图子 textview 值,通过此文档 http://controlingquality.blogspot.in/2011/08/playing-with-android-application.html 我看到这些行来访问 textview
ListView lvResults = solo.getCurrentListViews().get(0);
或 ArrayList vTextViewResults = solo.getCurrentTextViews(lvResults);
第一行获取屏幕上使用的第一个列表,第二行获取 ArrayList 中的所有 TextView 控件,但缺少 .getCurrentListViews() 方法。我使用的版本 robotium:robotium-solo:5.5.2
一些link也被引用Iterating through a List and clicking on list items in Robotium https://groups.google.com/forum/#!topic/robotium-developers/UY69TKCF5Fw
上网查了一下才知道,从4.0开始(不知道具体是哪个版本)一些方法被泛型方法代替了。
Prevoius 获取屏幕上使用的第一个列表的代码
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
我想在 Robotium 测试 class 中访问列表视图子 textview 值,通过此文档 http://controlingquality.blogspot.in/2011/08/playing-with-android-application.html 我看到这些行来访问 textview
ListView lvResults = solo.getCurrentListViews().get(0);
或 ArrayList vTextViewResults = solo.getCurrentTextViews(lvResults);
第一行获取屏幕上使用的第一个列表,第二行获取 ArrayList 中的所有 TextView 控件,但缺少 .getCurrentListViews() 方法。我使用的版本 robotium:robotium-solo:5.5.2
一些link也被引用Iterating through a List and clicking on list items in Robotium https://groups.google.com/forum/#!topic/robotium-developers/UY69TKCF5Fw
上网查了一下才知道,从4.0开始(不知道具体是哪个版本)一些方法被泛型方法代替了。
Prevoius 获取屏幕上使用的第一个列表的代码
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