I have a problem with viewPager on the android APIs 15 and 16, my si application is basically a simple remote control for a set-top box with three screens, where on the first screen you can choose which unit you want to control, the second and third are just screens with controls. Now the problem is that everything works fine on any other version of Android, but on API 15 and 16, when the application starts, I canβt use creen with boxes when I click anywhere where it detects actions on the second screen that are the controls when I sit down on the third screen and then back, the onCreateView for the first screen is called again and everything works fine. Here are the images of the first and second screens 
and here is my code for viewPager:
public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); switch (position) { case 0: return boxesFragment; case 1: return miscpadFragment; case 2: if (metrics.densityDpi == DisplayMetrics.DENSITY_MEDIUM) { return volPadFragment; } else return numberPadFragment; case 3: return numberPadFragment; } return null; } @Override public int getCount() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); switch(metrics.densityDpi){ case DisplayMetrics.DENSITY_MEDIUM: if (isTablet) { return 2; } else return 4; case DisplayMetrics.DENSITY_HIGH: if (isTablet) { return 2; } else return 3; case DisplayMetrics.DENSITY_XHIGH: if (isTablet) { return 2; } else return 3; case DisplayMetrics.DENSITY_XXHIGH: return 3; case DisplayMetrics.DENSITY_TV: return 2; } return 3; } @Override public CharSequence getPageTitle(int position) { Locale l = Locale.getDefault(); switch (position) { case 0: return getString(R.string.title_section1).toUpperCase(l); case 1: return getString(R.string.title_section2).toUpperCase(l); case 2: return getString(R.string.title_section3).toUpperCase(l); } return null; } }
and DepthPageTransformer, which I also use for animation:
public class DepthPageTransformer implements ViewPager.PageTransformer { private static final float MIN_SCALE = 0.8f; public void transformPage(View view, float position) { int pageWidth = view.getWidth(); if (position < -1) {
source share