title: ViewPagers in a ListView showing blank list items
body: <p><strong>[EDIT]</strong>: Thank you for all the meaningful answers, the problem is now solved, thank to your help. Similar issue: <a href="https://stackoverflow.com/questions/8394681/android-i-am-unable-to-have-viewpager-wrap-content">Android: I am unable to have ViewPager WRAP_CONTENT</a></p>
  
  <p>I'm trying to implement the UI of my app : I want a <code>ListView</code> with a <code>ViewPager</code> in each row.</p>
  
  <p>Here are my files :</p>
  
  <p><em>MainActivity.java</em></p>
  
  <pre><code>package com.condi;
  
  import android.app.ListActivity;
  import android.os.Bundle;
  import android.view.Menu;
  
  public class MainActivity extends ListActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          setListAdapter(new CardListAdapter(this, getFragmentManager()));
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  }
  </code></pre>
  
  <p><em>CardListAdapter.java</em></p>
  
  <pre><code>package com.condi;
  
  import java.util.List;
  
  import android.app.FragmentManager;
  import android.content.Context;
  import android.support.v4.view.ViewPager;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  
  public class CardListAdapter extends BaseAdapter {
  
      private Context context;
      private FragmentManager fragmentManager;
      private List&lt;Profile&gt; profiles;
  
      CardListAdapter(Context context, FragmentManager fragmentManager) {
          this.context = context;
          this.fragmentManager = fragmentManager;
          this.profiles = new DatabaseHelper(context).getProfiles();
      }
  
      @Override
      public int getCount() {
          return profiles.size();
      }
  
      @Override
      public Profile getItem(int position) {
          return profiles.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          convertView = View.inflate(context, R.layout.profile_card, null);
          CardPagerAdapter mCardPagerAdapter = new CardPagerAdapter(
                  fragmentManager);
          ViewPager viewPager = (ViewPager) convertView.findViewById(R.id.pager);
          viewPager.setAdapter(mCardPagerAdapter);
          viewPager.setId(R.id.pager);
          return convertView;
      }
  }
  </code></pre>
  
  <p><strong>profile_card.xml</strong> (issue came from  <code>wrap_content</code>).</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" &gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_marginBottom="4dp"
          android:layout_marginLeft="6dp"
          android:layout_marginRight="6dp"
          android:layout_marginTop="4dp"
          android:background="@drawable/card_background"
          android:orientation="vertical" &gt;
  
          &lt;android.support.v4.view.ViewPager
              android:id="@+id/pager"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p><em>CardPagerAdapter.java</em></p>
  
  <pre><code>package com.condi;
  
  import android.app.Fragment;
  import android.app.FragmentManager;
  import android.support.v13.app.FragmentPagerAdapter;
  
  public class CardPagerAdapter extends FragmentPagerAdapter {
  
      public CardPagerAdapter(FragmentManager fm) {
          super(fm);
      }
  
      @Override
      public Fragment getItem(int position) {
          switch (position) {
          case 0:
              return new Fragment1();
          case 1:
              return new Fragment2();
          }
          return null;
      }
  
      @Override
      public int getCount() {
          return 2;
      }
  }
  </code></pre>
  
  <p><em>Fragment1.java</em></p>
  
  <pre><code>package com.condi;
  
  import android.app.Fragment;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  public class Fragment1 extends Fragment {
  
      public Fragment1() {
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          return inflater.inflate(R.layout.preference_category, container, false);
      }
  }
  </code></pre>
  
  <p><em>Fragment2.java</em></p>
  
  <pre><code>package com.condi;
  
  import android.app.Fragment;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  public class Fragment2 extends Fragment {
  
      public Fragment2() {
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          return inflater.inflate(R.layout.preference_category, container, false);
      }
  }
  </code></pre>
  
  <p>The database that furnishes the profiles is working well.
  The problem is that I am getting an empty list with the correct number of item, but no <code>ViewPager</code> displayed at all. <a href="https://i.stack.imgur.com/hacm1.png" rel="nofollow noreferrer">screenshot of my app</a></p>
  
  <p>What am I doing wrong ?</p>