I have a ViewPager of 3 fragments. When every I switch to my third fragment, touching it in places where the previous fragment had touch events is activating those events.
Example: When I set the current item to 2 (Third fragment, Menu) and I click in the center, the button that I have in the center of item 1 (Second fragment, Intro) gets activated.
Edit: I just noticed that this happens not only to the previous fragment but the next one as well. When I was in item 1 I triggered an event in item 2.
This is my Adapter:
/**
* A simple pager adapter that represents 3 ScreenSlidePageFragment objects,
* in sequence.
*/
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
public ScreenSlidePagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
Fragment frag = new SetupFragment(SplashActivity.this, step);
return frag;
case 1:
Fragment frag2 =new IntroFragment(SplashActivity.this);
return frag2;
case 2:
Fragment frag3 = new MenuFragment(SplashActivity.this);
return frag3;
default:
throw new RuntimeException("No item at position " + position);
}
}
@Override
public int getCount() {
return 3;
}
}
Does anyone know a reason for this happening?