I use in my Android (4.0+) application fragment (in Activity) with a tab bar.
I want to create an Espresso test, but if I create the main activity and open the snippet. I get this exception:
java.lang.IllegalStateException: ViewPager does not have adapter instance. at com.astuetz.PagerSlidingTabStrip.setViewPager(PagerSlidingTabStrip.java:177) at cz.villamemories.detoxme.staticcontent.StaticContentFragment.onCreateView(StaticContentFragment.java:197)
My code in the snippet:
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mViewPagerAdapter = new StaticContentPagerAdapter( this.getChildFragmentManager(), mItemsList, categories); mPager.setAdapter(mViewPagerAdapter); mTabs.setViewPager(mPager);
Do you have a clue where there might be a problem? What's wrong?
android android-fragments android-testing android-espresso
Pepa zapletal
source share