weikipeng / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

How to click on custom listView item placed in a nested layouts ? #641

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create custom layout like this (I want to click on the image view in this 
layout)  https://gist.github.com/shivarajp/c6dff588df6cee1fdd30

2.The main layout is like this 
https://gist.github.com/shivarajp/4817a675b26d59dac0d6

3. I have my own custom view which is placed in the main layout and the other 
file (step 1) is the actual custom layout file.

What is the expected output? What do you see instead?
I want to click on the imageView in customlayout.xml can you please tell me how 
to do it.

What version of the product are you using? On what operating system?
robotium-solo-5.2.2-SNAPSHOT.jar

Please provide any additional information below.

This is what i tried
Its a static method to which i am passing solo object and performing click 
operation.

android.widget.ListView listView0 = (android.widget.ListView)  
solo.getView(android.widget.ListView.class, 0);
solo.clickOnView(listView0.getChildAt(0));
View view = listView0.getChildAt(0);
solo.clickOnView(solo.getView(view.findViewById(android.R.id.)));

Method 2 R.id. shows red mark

ArrayList<View> allViews = solo.getCurrentViews();
ArrayList<View> allViews2 = solo.getViews(allViews.get(2));
View allViews3  = allViews2.get(0);
solo.clickOnView(solo.getView(allViews3.findViewById(R.id.)));

Not able to access R.id. view ids

Original issue reported on code.google.com by shiva...@triveous.com on 1 Dec 2014 at 9:49

GoogleCodeExporter commented 9 years ago
What happens if you do this?

View view = listView0.getChildAt(0);
solo.clickOnView(view);

Original comment by renasr...@gmail.com on 3 Dec 2014 at 2:35

GoogleCodeExporter commented 9 years ago
When i do that it just clicks on the first row of the list view. But i want to 
click on the imageView on the first row of the listView.

Original comment by shiva...@triveous.com on 3 Dec 2014 at 6:51

GoogleCodeExporter commented 9 years ago
You could try to use solo.getCurrentViews(ImageView.class), identify which one 
of those ImageViews is the one your looking for and you want to click. 

Original comment by renasr...@gmail.com on 8 Dec 2014 at 5:22