title: Android ViewPager not showing content images
body: <p>In my app there is a viewpager which is used for displaying a set of pictures. However, When I launch the activity the viewpager is not showing any content even though I verified the getCount() method in my custom adapter class returns 1 using the debugger.</p>
  
  <p>My adapter layout:</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/layout_picture"
      android:clickable="true"&gt;
  
  &lt;ImageView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id ="@+id/iv_picture"/&gt;
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Picture"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>My ViewPager layout:</p>
  
  <pre><code>   &lt;android.support.v4.view.ViewPager
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/vp_pictures"
          android:visibility="visible"/&gt;
  </code></pre>
  
  <p>My custom adapter class:</p>
  
  <pre><code>public class PicturePagerAdapter extends PagerAdapter{
  
  Context context;
  LayoutInflater inflater;
  ArrayList&lt;Bitmap&gt; data;
  ViewPager pager;
  private boolean deleteEnable;
  
  public PicturePagerAdapter(Context ctx, ArrayList&lt;Bitmap&gt; data, ViewPager p, boolean delete_enable){
      this.context = ctx;
      this.data = data;
      this.pager = p;
      this.deleteEnable = delete_enable;
  }
  
  @Override
  public int getCount() {
      return data.size();
  }
  
  @Override
  public boolean isViewFromObject(View view, Object object) {
      return view == ((LinearLayout)object);
  }
  
  @Override
  public Object instantiateItem(ViewGroup container, final int position) {
  
      ImageView picture;
      LinearLayout layout_picture;
  
      inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View v = inflater.inflate(R.layout.pager_adapter_pictures, null);
      picture = (ImageView)v.findViewById(R.id.iv_picture);
      layout_picture = (LinearLayout)v.findViewById(R.id.layout_picture);
      BitmapDrawable drawable = new BitmapDrawable(data.get(position));
      picture.setImageDrawable(drawable);
      if(deleteEnable) {
          layout_picture.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  AlertDialog.Builder b = new AlertDialog.Builder(context);
                  b.setTitle(context.getResources().getString(R.string.actions_title));
                  b.setMessage(context.getResources().getString(R.string.actions_picture));
                  b.setNegativeButton(context.getResources().getString(R.string.delete_picture), new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          removeBitmapAt(pager, position);
                      }
                  });
              }
          });
      }
      container.addView(v);
      return v;
  }
  
  @Override
  public void destroyItem(ViewGroup container, int position, Object object) {
      ((ViewPager)container).removeView((LinearLayout) object);
  }
  
  public void addBitmap(Bitmap map){
      pager.setAdapter (null);
      this.data.add(map);
      pager.setAdapter(this);
  }
  
  public void removeBitmapAt(ViewPager pager, int index){
      pager.setAdapter (null);
      this.data.remove(index);
      pager.setAdapter (this);
  }
  </code></pre>
  
  <p>And finally this is how I setup the viewpager in my activity:</p>
  
  <pre><code>this.picturePager = (ViewPager) findViewById(R.id.vp_pictures);
  this.pagerAdapter = new PicturePagerAdapter(context, activityController.getCurrentBook().getPictures(), picturePager, false);
  this.picturePager.setAdapter(this.pagerAdapter);
  Toast.makeText(this, "Size:"+picturePager.getAdapter().getCount(),Toast.LENGTH_LONG).show();
  </code></pre>
  
  <p>Toast() in the above code will return 1, which is correct. However the ViewPager is not showing in my activity, please help.</p>