How to get focus of list item of listview in my android testcase using robotium?

2,020 views
Skip to first unread message

Addy

unread,
Sep 28, 2011, 9:49:10 AM9/28/11
to Robotium Developers
Hi,

In my android test project I used the robotium for testing some UI and
its events. Now whenever I have a activity with list and If i navigate
the list like up-down and get the current focused view then I always
get the listview as a current focused view but I want to the list item
which is actually focused. Anybody?

I am using

View view=getCurrentActivity().getCurrentFocus();

Is this right method for finding a current focused list item or I am
missing something. Thanks.

Saneesh Joseph

unread,
Sep 28, 2011, 10:16:13 AM9/28/11
to robotium-...@googlegroups.com
You can use,

ListView list = (ListView)getCurrentActivity().getCurrentFocus();

TextView view=(TextView) ( list.getSelectedView()   ) ;

This will return you the text view. However, success of this depends on the layout of the list item.

Best Regards,
Saneesh Joseph.



--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.
To post to this group, send email to robotium-...@googlegroups.com.
To unsubscribe from this group, send email to robotium-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotium-developers?hl=en.


Reply all
Reply to author
Forward
0 new messages