how to get focused child view from the parent view?

3,084 views
Skip to first unread message

Addy

unread,
Sep 29, 2011, 4:20:37 AM9/29/11
to Robotium Developers
Hi,

I am trying to test one application in which I focused one list item
using navigation key UP/DOWN,
Now my problem is whenever I get that Item by,


View parentView=getCurrentActivity().getCurrentFocus();

ArrayList<View> childView = new ArrayList<View>();

childView=getViews(parentView);
//here child and
parent views are same

for(int i=0;i<childView.size();i++)
{
if(childView.get(i).isFocused())
Log.e("The number of child view focused is:",i+"");
}


But here always childView is a same view as parentView. So I cant get
the childViews of parentView.

Thanks in advance.

Addy

unread,
Sep 29, 2011, 7:06:50 AM9/29/11
to Robotium Developers
Also, I have a problem if I have a list item focused then I am only
getting the Listview as focused view but I cant get the child of
listView (Listitem which one is focused) as a Focused list item.

And what about if any user test the app, then whenever he want to get
the focused view, then what will he get? either parent view in which
the focused view is lying or the focused view itself?

Thanks.

Yahor Paulavets

unread,
Sep 29, 2011, 7:31:29 AM9/29/11
to robotium-...@googlegroups.com
Hello,

Why do you need "focused" child?

Just get necessary view by id and use getChildAt(index) method to fetch any child you like.

For years of writing tests for Android I have never used "focused" child or whatever related to the focus.

Happy testing! (:

Best regards,
Yahor


--
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.


Addy

unread,
Sep 29, 2011, 8:22:53 AM9/29/11
to Robotium Developers
Thanks for your reply,

I am currently used navigation key to play it with robotium,

Like,

I am writing test case for android setting application,
and I am just send command ,

solo.sendKey(Solo.DOWN);
solo.sendKey(Solo.DOWN);
solo.sendKey(Solo.DOWN);
solo.sendKey(Solo.ENTER);
solo.sendKey(Solo.DOWN);
solo.sendKey(Solo.ENTER);


now I just want to check on which view robotium does
solo.sendKey(Solo.ENTER);

and I just print that view's name on adb.

that's why i want to get a focus able view at
solo.sendKey(Solo.ENTER);

On Sep 29, 4:31 pm, Yahor Paulavets <ypaulav...@agilefusion.com>
wrote:
Reply all
Reply to author
Forward
0 new messages