title: How to load data dinnamicaly inside ViewPager fragment from database
body: <p>I'm aiming to create app that having swipe gesture to switch between products. At first, i create app with navigation drawer. this drawer item/menu will load different fragment.</p>
  
  <p>in this particular fragment, named coupon, i want to implement the viewpager. this is what i achieve on my try:</p>
  
  <ol>
  <li><p>create coupon fragment which loaded when i click one of item in navigation drawer</p></li>
  <li><p>on CouponFragment.java i put:</p>
  
  <pre><code>mCustomPagerAdapter = new CustomPagerAdapter(getFragmentManager(), getActivity());
  
  mViewPager = (ViewPager) view.findViewById(R.id.pager);
  mViewPager.setAdapter(mCustomPagerAdapter);
  </code></pre></li>
  <li><p>on fragment_coupon.xml i put the ViewPager</p></li>
  <li><p>I Create CustomPagerAdapter that extends FragmentPagerAdapter:</p>
  
  <p>public class CustomPagerAdapter extends FragmentPagerAdapter {</p>
  
  <pre><code>protected Context mContext;
  
  public CustomPagerAdapter(FragmentManager fm, Context context) {
      super(fm);
      mContext = context;
  }
  
  @Override
  // This method returns the fragment associated with
  // the specified position.
  //
  // It is called when the Adapter needs a fragment
  // and it does not exists.
  public Fragment getItem(int position) {
  
      // Create fragment object
      Fragment fragment = new DemoFragment();
  
      // Attach some data to it that we'll
      // use to populate our fragment layouts
      Bundle args = new Bundle();
      args.putInt("page_position", position + 1);
      args.putString("coupon_name", "Promo Lorem Ipsum");
      args.putString("coupon_desc", "description is here");
  
      // Set the arguments on the fragment
      // that will be fetched in DemoFragment@onCreateView
      fragment.setArguments(args);
  
      return fragment;
  }
  
  @Override
  public int getCount() {
      return 3;
  }
  </code></pre>
  
  <p>}</p></li>
  <li><p>I create DemoFragment.java which loaded inside adapter:</p>
  
  <p>public class DemoFragment extends Fragment {</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      // Inflate the layout resource that'll be returned
      View rootView = inflater.inflate(R.layout.fragment_demo, container, false);
  
      // Get the arguments that was supplied when
      // the fragment was instantiated in the
      // CustomPagerAdapter
      Bundle args = getArguments();
      ((TextView) rootView.findViewById(R.id.text)).setText("Page " + args.getInt("page_position"));
      ((TextView) rootView.findViewById(R.id.test1)).setText("" + args.getString("coupon_name"));
      ((TextView) rootView.findViewById(R.id.test2)).setText("" + args.getString("coupon_desc"));
      return rootView;
  }
  </code></pre>
  
  <p>}</p></li>
  <li><p>I create fragment_demo.xml:</p>
  
  <p></p>
  
  <pre><code>&lt;TextView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:text="Page 0"
      android:id="@+id/text" /&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/test1"/&gt;
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/test2"/&gt;
  </code></pre>
  
  <p></p></li>
  </ol>
  
  <p><strong>my question:</strong></p>
  
  <ol start="2">
  <li>I want to load bunch of products there, let say like 20 products to swipe. how can i do that? i only got position, but not the product id to load the data</li>
  </ol>