title: how to stop listview refreshing in viewpager
body: <p>I am newbie to android. I'm trying to implement <code>viewpager</code> with 2 tab with a <code>listview</code> inside.
  The problem occurs when i <code>scroll.Listview</code> contains one <code>spinner</code> and three <code>textview</code> which will be generate using adapter. if i select item from the first spinner generated then i get values of it.but when i go down an select different spinner then spinner which i selected earlier gets selected to position 0.</p>
  
  <p>Here's the code</p>
  
  <pre><code>public class Baggage_Home extends AppCompatActivity{
  
  TabLayout tabs;
  private ViewPager viewPager;
  public static TextView extra_total;
  
  
   private int[] tabIcons = {
          R.drawable.ic_business_center_black_24dp,
          R.drawable.ic_room_service_black_24dp,
  
  };
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.baggage_meal);
  
      extra_total=(TextView)findViewById(R.id.extra_total);
      viewPager = (ViewPager) findViewById(R.id.viewpager);
      viewPager.setOffscreenPageLimit(2);
      setupViewPager(viewPager);
  
   extra_total.setText("₹ "+String.valueOf(InternationalRoundTrip.total));
      tabs = (TabLayout) findViewById(R.id.tabs);
      tabs.setupWithViewPager(viewPager);
      setupTabIcons();
  
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      toolbar.setTitle("Extra Services");
      setSupportActionBar(toolbar);
  
  
  
  }
  
  
  private void setupTabIcons() {
      tabs.getTabAt(0).setIcon(tabIcons[0]);
      tabs.getTabAt(1).setIcon(tabIcons[1]);
  
  }
  
  
  
  @Override
  public void onBackPressed() {
      if(!Flight_search_new.trm_cty_code_cnt.equals("IN") || !Flight_search_new.to_cty_code_cnt.equals("IN")) {
                  if(Flight_search_new.valtype=="Internationaloneway"){
                      Intent intent = new Intent(Baggage_Home.this,FlightBookingPage_Int.class);
                      startActivity(intent);
                  }else{
                      Intent intent = new Intent(Baggage_Home.this,RoundFlightBookingPage_Int.class);
                      intent.putExtra("BAGGAGE","abcd");
                      startActivity(intent);
                  }
  
              }else
              {
                  Intent intent = new Intent(Baggage_Home.this,FlightBookingPage.class);
                  startActivity(intent);
              }
  }
  
  class ViewPagerAdapter extends FragmentPagerAdapter {
      private final List&lt;Fragment&gt; mFragmentList = new ArrayList&lt;&gt;();
      private final List&lt;String&gt; mFragmentTitleList = new ArrayList&lt;&gt;();
  
      public ViewPagerAdapter(FragmentManager manager) {
          super(manager);
      }
  
      @Override
      public Fragment getItem(int position) {
          return mFragmentList.get(position);
      }
  
      @Override
      public int getCount() {
          return mFragmentList.size();
      }
  
      public void addFragment(Fragment fragment, String title) {
          mFragmentList.add(fragment);
          mFragmentTitleList.add(title);
      }
  
      @Override
      public CharSequence getPageTitle(int position) {
          return mFragmentTitleList.get(position);
      }
  }
  
  
  private void setupViewPager(ViewPager viewPager) {
      ViewPagerAdapter adapter = new 
  ViewPagerAdapter(getSupportFragmentManager());
      adapter.addFragment(new Baggage_display(), "Baggage");
      adapter.addFragment(new Meal_display(), "Meal");
      viewPager.setAdapter(adapter);
  }
  }
  </code></pre>
  
  <p><strong>XML FOR BAGGAGE CLASS</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:id="@+id/layout1"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  &gt;
  
  &lt;android.support.design.widget.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:theme="@style/AppTheme.AppBarOverlay"
      &gt;
  
      &lt;android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="?attr/colorPrimary"
          app:popupTheme="@style/AppTheme.PopupOverlay" /&gt;
  
  
  
  &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
  
      android:orientation="horizontal"
      android:layout_height="wrap_content"
     &gt;
  
      &lt;android.support.design.widget.TabLayout
          android:layout_width="match_parent"
          android:id="@+id/tabs"
          android:layout_height="wrap_content"
          app:tabMaxWidth="0dp"
          app:tabGravity="fill"
          app:tabMode="fixed"
  
          &gt;
  
          &lt;android.support.design.widget.TabItem
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="Baggage"
  
              /&gt;
  
          &lt;android.support.design.widget.TabItem
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="Meal"
  
              /&gt;
  
      &lt;/android.support.design.widget.TabLayout&gt;
  
  
  
  &lt;/LinearLayout&gt;
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textSize="25dp"
      android:textColor="@color/btn_color"
      android:id="@+id/extra_total"
      android:layout_gravity="bottom|center"
      /&gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id="@+id/viewpager"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_below="@+id/layout1"
          app:layout_behavior="@string/appbar_scrolling_view_behavior"
          /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>BAGGAGE DISPLAY CLASS</strong></p>
  
  <pre><code>public class Baggage_display extends Fragment {
  
  
  ArrayList&lt;Baggage_details&gt; bagdetails=new ArrayList&lt;Baggage_details&gt;();
  Baggage_Adapter baggageAdapter;
  ListView listView;
  public static ArrayList&lt;String&gt; title_adult_bag_arr=new ArrayList&lt;String&gt;();
  public static ArrayList&lt;String&gt; title_adult_bag_arr_rtn=new ArrayList&lt;String&gt;();
  public static ArrayList&lt;String&gt; title_child_bag_arr=new ArrayList&lt;String&gt;();
  public static ArrayList&lt;String&gt; title_child_bag_arr_rtn=new ArrayList&lt;String&gt;();
  
  
  LinearLayout lvs;
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      View views = inflater.inflate(R.layout.baggage_display, container, false);
  
      listView=(ListView)views.findViewById(R.id.listView);
  
      bagdetails.clear();
      title_adult_bag_arr.clear();
      title_adult_bag_arr_rtn.clear();
      title_child_bag_arr.clear();
      title_child_bag_arr_rtn.clear();
  
      for (int i = 0; i &lt; Integer.parseInt(Flight_search_new.adult); i++)
      {
  
          if(Flight_search_new.valtype.equals("Internationalround"))
          {
              if(InternationalRoundTrip.api.equals("galileo"))
              {
                  if (InternationalRoundTrip.provider.equals("ACH"))
                  {
                      bagdetails.add(new Baggage_details("Onward",  Flight_search_new.trm_cty_code +"-"+ Flight_search_new.to_cty_code,"Adult -"+(i+1),RoundFlightBookingPage_Int.ach_adl_baggage));
                      baggageAdapter=new Baggage_Adapter(getContext(),bagdetails);
  
  
                      if(RoundFlightBookingPage_Int.ach_adl_baggage_rtn != null) {
                          bagdetails.add(new Baggage_details("Return", Flight_search_new.to_cty_code + "-" + Flight_search_new.trm_cty_code, "Adult -" + (i + 1), RoundFlightBookingPage_Int.ach_adl_baggage_rtn));
                          baggageAdapter = new Baggage_Adapter(getContext(), bagdetails);
                      }
                      System.out.println("WWWWW"+RoundFlightBookingPage_Int.ach_adl_baggage.toString());
                      System.out.println("RRRRR"+RoundFlightBookingPage_Int.ach_adl_baggage_rtn.toString());
  
                  }
                  else
                  {
  
                  }
              }
              else
              {
                  bagdetails.add(new Baggage_details("Onward",  Flight_search_new.trm_cty_code +"-"+ Flight_search_new.to_cty_code,"Adult -"+(i+1),RoundFlightBookingPage_Int.titlebag));
                  baggageAdapter=new Baggage_Adapter(getContext(),bagdetails);
  
                  if(RoundFlightBookingPage_Int.titlebag_return != null) {
                      bagdetails.add(new Baggage_details("Return", Flight_search_new.to_cty_code + "-" + Flight_search_new.trm_cty_code, "Adult -" + (i + 1), RoundFlightBookingPage_Int.titlebag_return));
                      baggageAdapter = new Baggage_Adapter(getContext(), bagdetails);
                  }
              }
  
          }
          else{
              Toast.makeText(getContext(), "Not Int Round", Toast.LENGTH_SHORT).show();
          }
  
      }
  
  
  
      if(Integer.parseInt(Flight_search_new.child) &gt; 0) {
          for (int i = 0; i &lt; Integer.parseInt(Flight_search_new.child); i++) {
  
              if (InternationalRoundTrip.api.equals("galileo")) {
                  if (InternationalRoundTrip.provider.equals("ACH")) {
                      bagdetails.add(new Baggage_details("Onward", Flight_search_new.trm_cty_code + "-" + Flight_search_new.to_cty_code, "Child -" + (i + 1), RoundFlightBookingPage_Int.ach_child_bag));
                      baggageAdapter = new Baggage_Adapter(getContext(), bagdetails);
  
  
                      if (RoundFlightBookingPage_Int.ach_adl_baggage_rtn != null) {
                          bagdetails.add(new Baggage_details("Return", Flight_search_new.to_cty_code + "-" + Flight_search_new.trm_cty_code, "Child -" + (i + 1), RoundFlightBookingPage_Int.ach_chi_bag_rtn));
                          baggageAdapter = new Baggage_Adapter(getContext(), bagdetails);
                      }
                      System.out.println("CCCCCC"+RoundFlightBookingPage_Int.ach_child_bag.toString());
                      System.out.println("PPPPP"+RoundFlightBookingPage_Int.ach_chi_bag_rtn.toString());
  
                  } else {
  
                  }
              } else {
                  bagdetails.add(new Baggage_details("Onward",  Flight_search_new.trm_cty_code +"-"+ Flight_search_new.to_cty_code,"Child -"+(i+1),RoundFlightBookingPage_Int.titlebag));
                  baggageAdapter=new Baggage_Adapter(getContext(),bagdetails);
  
                  if(RoundFlightBookingPage_Int.titlebag_return!= null) {
                      bagdetails.add(new Baggage_details("Return", Flight_search_new.to_cty_code + "-" + Flight_search_new.trm_cty_code, "Child -" + (i + 1), RoundFlightBookingPage_Int.titlebag_return));
                      baggageAdapter = new Baggage_Adapter(getContext(), bagdetails);
                  }
  
              }
          }
      }
  
  
  
      return views;
  
  }
  
  
  }
  </code></pre>
  
  <p><strong>MEAL DISPLAY CLASS</strong></p>
  
  <pre><code>public class Meal_display extends Fragment {
  
  ArrayList&lt;Meal_details&gt; bagdetails=new ArrayList&lt;Meal_details&gt;();
  public static ArrayList&lt;String&gt; title_adult_meal_arr=new ArrayList&lt;String&gt;();
  public static ArrayList&lt;String&gt; title_adult_meal_arr_rtn=new ArrayList&lt;String&gt;();
  public static ArrayList&lt;String&gt; title_child_meal_arr=new ArrayList&lt;String&gt;();
  public static ArrayList&lt;String&gt; title_child_meal_arr_rtn=new ArrayList&lt;String&gt;();
  Meal_Adapter baggageAdapter;
  ListView listView;
  
  
  
  LinearLayout lvs;
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      View views = inflater.inflate(R.layout.meal_display, container, false);
  
      listView=(ListView)views.findViewById(R.id.listView);
      title_adult_meal_arr.clear();
      title_adult_meal_arr_rtn.clear();
      title_child_meal_arr.clear();
      title_child_meal_arr_rtn.clear();
  
  
      for (int i = 0; i &lt; Integer.parseInt(Flight_search_new.adult); i++)
      {
  
          if(Flight_search_new.valtype.equals("Internationalround"))
          {
              if(InternationalRoundTrip.api.equals("galileo"))
              {
                  if (InternationalRoundTrip.provider.equals("ACH"))
                  {
                      bagdetails.add(new Meal_details("Onward",  Flight_search_new.trm_cty_code +"-"+ Flight_search_new.to_cty_code,"Adult -"+(i+1),RoundFlightBookingPage_Int.ach_adl_meal_onward));
                      baggageAdapter=new Meal_Adapter(getContext(),bagdetails);
  
  
                      if(RoundFlightBookingPage_Int.ach_adl_meal_rtn != null &amp;&amp; !RoundFlightBookingPage_Int.ach_adl_meal_rtn.isEmpty())
                      {
                          bagdetails.add(new Meal_details("Return", Flight_search_new.to_cty_code + "-" + Flight_search_new.trm_cty_code, "Adult -" + (i + 1), RoundFlightBookingPage_Int.ach_adl_meal_rtn));
                          baggageAdapter = new Meal_Adapter(getContext(), bagdetails);
                      }
  
                  }
                  else
                  {
  
                  }
              }
              else
              {
                  for (int k = 0; k &lt; Round_ViewFlight.final_sec_meal.size(); k++) {
                      String src_des = Round_ViewFlight.final_sec_meal.get(k);
                      bagdetails.add(new Meal_details("Onward", src_des, "Adult -" + (i + 1), RoundFlightBookingPage_Int.titlemeal));
                      baggageAdapter = new Meal_Adapter(getContext(), bagdetails);
                  }
  
                  if(RoundFlightBookingPage_Int.titlemeal_return != null &amp;&amp; !RoundFlightBookingPage_Int.titlemeal_return.isEmpty())
                  {
  
                      for (int k = 0; k &lt; Round_ViewFlight.final_sec_meal_return.size(); k++) {
                          String src_des1 = Round_ViewFlight.final_sec_meal_return.get(k);
                          bagdetails.add(new Meal_details("Return", src_des1, "Adult -" + (i + 1), RoundFlightBookingPage_Int.titlemeal_return));
                          baggageAdapter = new Meal_Adapter(getContext(), bagdetails);
                      }
                  }
  
  
              }
          }
          else{
              Toast.makeText(getContext(), "Not Int Round", Toast.LENGTH_SHORT).show();
          }
  
      }
  
  
      if(Integer.parseInt(Flight_search_new.child) &gt; 0) {
          for (int i = 0; i &lt; Integer.parseInt(Flight_search_new.child); i++) {
  
              if (InternationalRoundTrip.api.equals("galileo")) {
                  if (InternationalRoundTrip.provider.equals("ACH")) {
                      bagdetails.add(new Meal_details("Onward", Flight_search_new.trm_cty_code + "-" + Flight_search_new.to_cty_code, "Child -" + (i + 1), RoundFlightBookingPage_Int.ach_child_meal));
                      baggageAdapter = new Meal_Adapter(getContext(), bagdetails);
  
  
                      if (RoundFlightBookingPage_Int.ach_adl_baggage_rtn != null &amp;&amp; !RoundFlightBookingPage_Int.ach_adl_baggage_rtn.isEmpty()) {
                          bagdetails.add(new Meal_details("Return", Flight_search_new.to_cty_code + "-" + Flight_search_new.trm_cty_code, "Child -" + (i + 1), RoundFlightBookingPage_Int.ach_child_meal_rtn));
                          baggageAdapter = new Meal_Adapter(getContext(), bagdetails);
                      }
  
                  } else {
  
                  }
              }
              else {
                  for (int k = 0; k &lt; Round_ViewFlight.final_sec_meal.size(); k++) {
                      String src_des = Round_ViewFlight.final_sec_meal.get(k);
                      bagdetails.add(new Meal_details("Onward", src_des, "Child -" + (i + 1), RoundFlightBookingPage_Int.titlemeal));
                      baggageAdapter = new Meal_Adapter(getContext(), bagdetails);
                  }
  
                  if(RoundFlightBookingPage_Int.titlemeal_return != null &amp;&amp; !RoundFlightBookingPage_Int.titlemeal_return.isEmpty())
                  {
                      for (int k = 0; k &lt; Round_ViewFlight.final_sec_meal_return.size(); k++) {
                          String src_des1 = Round_ViewFlight.final_sec_meal_return.get(k);
                          bagdetails.add(new Meal_details("Return", src_des1, "Child -" + (i + 1), RoundFlightBookingPage_Int.titlemeal_return));
                          baggageAdapter = new Meal_Adapter(getContext(), bagdetails);
                      }
                  }
  
              }
  
          }
      }
  
  
  
      listView.setAdapter(baggageAdapter);
  
  
      return views;
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>GETTER SETTER FOR MEALCLASS</strong></p>
  
  <pre><code>public class Meal_Adapter extends BaseAdapter {
  Context context;
  public static ArrayList&lt;String&gt; spinner_items=new ArrayList&lt;String&gt;();
  public static ArrayList&lt;Meal_details&gt; rowItems;
  public static ArrayList&lt;String&gt; jeet_aar_meal=new ArrayList&lt;String&gt;();;
  
  ArrayList&lt;String&gt; Bag_selected_amount= new ArrayList&lt;String&gt;();
  ArrayList&lt;String&gt; Bag_selected__key= new ArrayList&lt;String&gt;();
  
  
  
  Meal_Adapter(Context context, ArrayList rowItems) {
  
      this.context = context;
      this.rowItems = rowItems;
  
  }
  @Override
  public int getCount() {
      return rowItems.size();
  }
  
  @Override
  public Object getItem(int position) {
      return rowItems.get(position);
  }
  
  @Override
  public long getItemId(int position)
  {
      return rowItems.indexOf(getItem(position));
  }
  
  /* private view holder class */
  private class ViewHolder {
      TextView sector,status;
      TextView title_count;
      Spinner spinner;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent)
  {
      final ViewHolder holder;
      LayoutInflater mInflater = (LayoutInflater) context
              .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
      if (convertView == null) {
          convertView = mInflater.inflate(R.layout.meal_adapter, null);
          holder = new ViewHolder();
      }
      else
      {
          holder = (ViewHolder) convertView.getTag();
      }
      holder.status = (TextView) convertView.findViewById(R.id.meal_status);
      holder.sector = (TextView) convertView.findViewById(R.id.sector);
      holder.title_count = (TextView) convertView.findViewById(R.id.title_count);
      holder.spinner = (Spinner) convertView.findViewById(R.id.spinner);
  
      try
      {
          final Meal_details row_pos = rowItems.get(position);
  
          String status = String.valueOf(row_pos.getstatus());
          String title_count = String.valueOf(row_pos.gettitle_count());
          String sector=String.valueOf(row_pos.getsector_name());
  
          holder.status.setText(status);
          holder.sector.setText(sector);
          holder.title_count.setText(title_count);
  
          holder.spinner.setTag(title_count+status+sector);
          holder.spinner.setOnItemSelectedListener(MealSelectedListener);
  
              spinner_items = row_pos.getbaggage_list();
  
  
  
  
          holder.spinner = spinnerDetails(convertView, R.id.spinner, String.valueOf(rowItems.get(position).getbaggage_list()));
      }
      catch (Exception e)
      {
          Log.e("PASS_ADAP ERROR:", e.getMessage());
      }
      convertView.setTag(holder);
      return convertView;
  }
  
  private Spinner spinnerDetails(View v, int resId, String text) {
      Spinner mySpinner = (Spinner) v.findViewById(resId);
  
      @SuppressWarnings({ "unchecked", "rawtypes" })
      ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(context,
              android.R.layout.simple_spinner_dropdown_item,
              spinner_items);
      mySpinner.setAdapter(spinnerArrayAdapter);
  
      return mySpinner;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>GETTER SETTER FOR BAGGAGE CLASS</strong></p>
  
  <pre><code>    public class Baggage_Adapter extends BaseAdapter {
  Context context;
  public static ArrayList&lt;Baggage_details&gt; rowItems;
  public static ArrayList&lt;String&gt; spinner_items=new ArrayList&lt;String&gt;();
  public static ArrayList&lt;String&gt; jeet_aar_bag=new ArrayList&lt;String&gt;();
  
  ArrayList&lt;String&gt; Bag_selected_amount= new ArrayList&lt;String&gt;();
  ArrayList&lt;String&gt; Bag_selected__key= new ArrayList&lt;String&gt;();
  
  Baggage_Adapter(Context context, ArrayList rowItems) {
  
      this.context = context;
      this.rowItems = rowItems;
  
  }
  @Override
  public int getCount() {
      return rowItems.size();
  }
  
  @Override
  public Object getItem(int position) {
      return rowItems.get(position);
  }
  
  @Override
  public long getItemId(int position)
  {
      return rowItems.indexOf(getItem(position));
  }
  
  /* private view holder class */
  private class ViewHolder {
      TextView sector,status;
      TextView title_count;
      Spinner spinner;
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent)
  {
      final ViewHolder holder;
      LayoutInflater mInflater = (LayoutInflater) context
              .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
      if (convertView == null) {
          convertView = mInflater.inflate(R.layout.baggage_adapter, null);
          holder = new ViewHolder();
      }
      else
      {
          holder = (ViewHolder) convertView.getTag();
      }
      holder.status = (TextView) convertView.findViewById(R.id.bag_status);
      holder.sector = (TextView) convertView.findViewById(R.id.sector);
      holder.title_count = (TextView) convertView.findViewById(R.id.title_count);
      holder.spinner = (Spinner) convertView.findViewById(R.id.spinner);
      try
      {
          final Baggage_details row_pos = rowItems.get(position);
  
          String status = String.valueOf(row_pos.getstatus());
          String title_count = String.valueOf(row_pos.gettitle_count());
          String sector=String.valueOf(row_pos.getsector_name());
  
          holder.status.setText(status);
          holder.sector.setText(sector);
          holder.title_count.setText(title_count);
          holder.spinner.setTag(title_count+status+sector);
          holder.spinner.setSelected(true);
          holder.spinner.setOnItemSelectedListener(BaggageSelectedListener);
  
              spinner_items = row_pos.getbaggage_list();
  
  
  
          holder.spinner = spinnerDetails(convertView, R.id.spinner, String.valueOf(rowItems.get(position).getbaggage_list()));
      }
      catch (Exception e)
      {
          Log.e("PASS_ADAP ERROR:", e.getMessage());
      }
      convertView.setTag(holder);
      return convertView;
  }
  
  private Spinner spinnerDetails(View v, int resId, String text) {
      Spinner mySpinner = (Spinner) v.findViewById(resId);
  
      @SuppressWarnings({ "unchecked", "rawtypes" })
      ArrayAdapter spinnerArrayAdapter = new ArrayAdapter(context,
              android.R.layout.simple_spinner_dropdown_item,
              spinner_items);
      mySpinner.setAdapter(spinnerArrayAdapter);
  
      return mySpinner;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Can anyone guide me where I'm going wrong.</p>
  
  <p>I have used </p>
  
  <blockquote>
    <p>viewPager.setOffscreenPageLimit(2); </p>
  </blockquote>
  
  <p>but it does not seem to work.</p>