Im hoping someone can help me out with this, in ddms hierarchy is as follows:
(0) ListView
(0) LinearLayout
(0) LinearLayout
(0)TextView:Value 1
(1)TextView:Value 2
(2)TextView:Value 3
(1)View
(2) LinearLayout
(1) LinearLayout
(0) LinearLayout
(0)TextView:Value 4
(1)TextView:Value 5
(2)TextView:Value 6
(1)View
(2) LinearLayout
What im trying to do is use robotium to confirm the values in the text views. my problem is the second set of views have the same resource-id, for example Value 1 and Value 4 both have a resource id of com.myapp.this:id/TopEntry
is there any way to use robotium to target views in a stepwise manner i.e get view 0,1,0 etc.
currently my code to check the content of a view is:
public String checkView(String theview, String expected)
{
string actual = "";
string result = "";
TextView view = (TextView) solo.getView(theview);
actual = (String) view.getText();
assertEquals("viewChecked",expected,actual);
--------- code continues ---------------
}
so for my example i would be calling the code by using:
checkView("TopEntry","Value 1");
checkView("TopEntry","Value 4"); <---------------and heeeeers the problem
Solo.getView(int id, int index) is what you should use. Index will change from 0 to X depending on how many Views are sharing the same ID.