title: Fragment Added in View Pager Load Wrong Data
body: <p>I have Total 7 fragments in view pager, I am using same fragment in the all the pager item as <code>ProductListingFragment</code>. And Fill Data on <code>public void setUserVisibleHint(boolean isVisibleToUser)</code> getting called. Now first fragment works fine but when I move to second fragment it is not fill the data in adapter and it show the data of second fragment in third fragment.</p>
  
  <p>Here is my code to add Child fragment in Viewpager :</p>
  
  <pre><code>viewPager = (ViewPager) view.findViewById(R.id.tiresViewpager);
  
      viewPager.setOffscreenPageLimit(0);
  
  
  
      viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  
          @Override
          public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
  
          }
  
          @Override
          public void onPageSelected(int position) {
              pagePosition = position;
              viewPager.setCurrentItem(pagePosition);
  
          }
  
          @Override
          public void onPageScrollStateChanged(int state) {
  
          }
      });
  
      tabLayout = (TabLayout) view.findViewById(R.id.tabs);
  
      return view;
  }
  
  @Override
  public void getVolleyRequestResponse(VolleyRequestResponse volleyResponse) {
  
      switch (volleyResponse.type) {
  
          case 0:
              try {
  
                  JSONObject objJson = new JSONObject(volleyResponse.output);
  
                  if (objJson.optInt(Param.KEY_STATUS_CODE) == Param.SUCCESS_CODE) {
  
                      adapter = new ViewPagerAdapter(getChildFragmentManager());
  
                      JSONArray jsonArray = objJson.getJSONArray("data");
  
                      for (int i = 0; i &lt; jsonArray.length(); i++) {
  
                          JSONObject categoryObject = jsonArray.getJSONObject(i);
                          adapter.addFragment(new ProductListingFragment(), categoryObject.getString("name"));
                          categoryId.add(categoryObject.getString("id"));
                      }
                      viewPager.setAdapter(adapter);
                      tabLayout.setupWithViewPager(viewPager);
                  }
  
              } catch (Exception e) {
                  e.printStackTrace();
              }
              break;
      }
  }
  
  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);
      }
  }
  </code></pre>
  
  <p>Hear is the code to load data in fragment</p>
  
  <pre><code>@Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_productlisting, container, false);
  
      setHasOptionsMenu(true);
  
  
      rv_Products = (RecyclerView) view.findViewById(R.id.rv_product);
  
      return view;
  }
  
  @Override
  public void setUserVisibleHint(boolean isVisibleToUser) {
  
      super.setUserVisibleHint(isVisibleToUser);
  
      if (isVisibleToUser) {
  
          handler = new Handler();
          list = new ArrayList&lt;&gt;();
          getProductList();
      }
  }
  
  
  public static void setGrid(Activity activity) {
      isList = false;
      GridLayoutManager lm = new GridLayoutManager(activity, 2);
      rv_Products.setLayoutManager(lm);
      adapter = new ProductFeatureAdapter(list, rv_Products, "grid");
      rv_Products.setAdapter(adapter);
  }
  
  public void getProductList() {
  
      new VolleyRequest(getActivity(), VolleyRequest.Method.POST, Url.getProductList, Param.productList(TiresFragment.categoryId.get(TiresFragment.pagePosition), page_count + ""), 0, true, this);
  }
  
  @Override
  public void getVolleyRequestResponse(VolleyRequestResponse volleyResponse) {
  
      switch (volleyResponse.type) {
  
          case 0:
              try {
  
                  JSONObject objJson = new JSONObject(volleyResponse.output);
  
                  if (objJson.optInt(Param.KEY_STATUS_CODE) == Param.SUCCESS_CODE) {
  
                      JSONArray featureProductArray = objJson.getJSONArray("response");
                      total_page = objJson.getInt("totalPages");
  
                      if (!isLoading) {
  
                          for (int i = 0; i &lt; featureProductArray.length(); i++) {
  
                              JSONObject object = featureProductArray.getJSONObject(i);
  
                              list.add(new Product(object.getString("id"),
                                      object.getString("productname"),
                                      "",
                                      object.getString("imageurl"),
                                      object.getString("price"),
                                      "",
                                      false,
                                      false,
                                      false,
                                      0,
                                      0));
                          }
  
                      } else {
  
                          ArrayList&lt;Product&gt; tmp_list = new ArrayList&lt;&gt;();
  
                          for (int i = 0; i &lt; featureProductArray.length(); i++) {
  
                              JSONObject object = featureProductArray.getJSONObject(i);
  
                              tmp_list.add(new Product(object.getString("id"),
                                      object.getString("name"),
                                      object.getString("category"),
                                      object.getString("imageurl"),
                                      object.getString("price"),
                                      object.getString("type"),
                                      false,
                                      false,
                                      false,
                                      0,
                                      0));
                          }
  
                          list.addAll(tmp_list);
                      }
  
                      set_recycler();
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }
              break;
      }
  }
  
  private void set_recycler() {
  
          Log.e("AAKASH", "IF LOAD " + isLoading + "");
          Log.e("AAKASH", "IF PAGE COUNT " + page_count + "");
          Log.e("AAKASH", "IF TOTAL PAGE " + total_page + "");
          isList = false;
          GridLayoutManager lm = new GridLayoutManager(getActivity(), 2);
          rv_Products.setLayoutManager(lm);
          Log.i("niral", "FRAGMENT CALLLED  SET ADAPTER " + TiresFragment.pagePosition);
  
          adapter = new ProductFeatureAdapter(list, rv_Products, "grid");
          rv_Products.setAdapter(adapter);
          adapter.notifyDataSetChanged();
  </code></pre>