Brinda K
Brinda K

Reputation: 765

Android:Robotium: Tab click with only icon

I have tab layout.That has only icons not text.I tried with clickOnImageButton and ClickOnButton clickOnImage and also pressOnMenuItem(R.drwable.icon)but not worked.How can i do this with solo? Note: Image View present at the top of the tab.(tab is at bottom)

Upvotes: 1

Views: 2614

Answers (3)

kamal_prd
kamal_prd

Reputation: 543

you can use method solo.clickOnView(solo.getView(resourceId));
where resourceId could be something like R.id.id_Of_Button.

Upvotes: 2

Paul Harris
Paul Harris

Reputation: 5819

Tabhosts are evil. Luckily i also have had to automate them and so know the answer.

what you do is you have to get the tab bar view (android.R.id.tabs) and then cast it to a Tabhost or a ViewGroup then you can get each of the tabs via .getChildAt(x) where x is the index of the tabs.

ViewGroup tabs = (ViewGroup) solo.getView(android.R.id.tabs);
View viewYouWantToDoStuffWith = tabs.getChildAt(x); //change x to the index you want.

In your case you would then want something like:

solo.clickOnView(viewYouWantToDoStuffWith);

Upvotes: 7

Chintan Khetiya
Chintan Khetiya

Reputation: 16152

see this link in that they are using image + text. so remove the text made as image that you have to do it.

http://www.androidhive.info/2011/08/android-tab-layout-tutorial/

this is only for text you can set that with image and made as custom tab.

http://www.androidpeople.com/android-tabhost-tutorial-part-1

Hope it will work for you .

Upvotes: 0

Related Questions