I have ViewPager with N tabs with StickyListHeadersListView inside each of them. I'd like to perform click on one of the list item. How could I do that? thanks!
PS: I'm interested in Espresso test code only
I have ViewPager with N tabs with StickyListHeadersListView inside each of them. I'd like to perform click on one of the list item. How could I do that? thanks!
PS: I'm interested in Espresso test code only
I've found the solution myself. The main issue - StickyListHeadersListView is a wrapper around ListView, it doesn't extend ListView. So we can't work with adapter directly, but we can do this:
onData(anything()).inAdapterView(allOf(
isAssignableFrom(AdapterView.class),
isDescendantOfA(withId(R.id.list)),
isDisplayed()))
.atPosition(1).perform(click());
Put this code in method where you are adding your view in viewPager:-
for(int i=0;i<arrPagerItems.size();i++)
{
View viewPager;
ListView listView;
viewPager = inflater.inflate(R.layout.layout_pager,null);
listView = (ListView) viewPager.findViewById(R.id.listView);
listChat.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View listView,int position,long arg3) {
//do your task
}
});
viewPagerAdapter.addView(viewPager, i);
viewPagerAdapter.notifyDataSetChanged();
}
With Listview, you put into fragment.view pager have fragment. after you can check click listitem in fragment. Custom :https://github.com/JakeWharton/ViewPagerIndicator