title: Dynamic listview with custom adapter in viewpager
body: <p>I try to create viewpager with two fragments. In one fragment I try to create listview with dynamic content.</p>
  
  <p>main.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/main"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
      &lt;com.example.pkg.views.CustomViewPager
          android:id="@+id/view_pager"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
          &lt;android.support.v4.view.PagerTabStrip
                  android:id="@+id/pager_title"
                  android:paddingBottom="10dp"
                  android:paddingTop="10dp"
                  android:textAppearance="@style/PagerTabStripText"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_gravity="top" /&gt;
      &lt;/com.example.pkg.views.CustomViewPager&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>In main activity class I use own CustomFragmentAdapter with overrided getItem(int index) method.</p>
  
  <pre class="lang-java prettyprint-override"><code>@Override
  public Fragment getItem(int i) {
  switch (i) {
      case 0:
          return new List();
  </code></pre>
  
  <p>Class List extends Fragment:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class List extends Fragment {
      private PointManager pointManager;
      private ListView list ;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.list, container, false);
          list = (ListView) rootView.findViewById(R.id.point_list);
          return rootView;
      }
  
      @Override
      public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
  
          pointManager = PointManager.getInstance(getActivity());
  
          ListViewAdapter adapter = new ListViewAdapter(getActivity(), R.id.point_list, pointManager.getPoints());
          list.setAdapter(adapter);
          list.invalidate();
      }
  
      @Override
      public void onResume() {
          super.onResume();
          ListViewAdapter adapter = new ListViewAdapter(getActivity(), R.id.point_list, pointManager.getPoints());
          list.setAdapter(adapter);
          list.invalidate();
      }
  }
  </code></pre>
  
  <p>list.xml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"&gt;
      &lt;ListView
              android:id="@+id/point_list"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:background="@android:color/white"
              android:divider="#ffdead"
              android:dividerHeight="1dp"
              android:listSelector="@drawable/list_selector" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>ListViewAdapter:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class ListViewAdapter extends ArrayAdapter&lt;Point&gt; {
      private final Activity activity;
      private List&lt;Point&gt; points;
  
      public ListViewAdapter(Activity context, int textViewResourceId, List&lt;Point&gt; objects) {
          super(context, textViewResourceId, objects);
          this.activity = context;
          this.points = objects;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parentView) {
          ViewHolder viewHolder;
  
          View rowView = convertView;
  
          if(rowView == null) {
              LayoutInflater inflater = activity.getLayoutInflater();
              rowView = inflater.inflate(R.layout.custom_list, parentView, false);
  
              viewHolder = new ViewHolder();
              viewHolder.title = (TextView) rowView.findViewById(R.id.notification_title);
              viewHolder.description = (TextView) rowView.findViewById(R.id.notification_desc);
              viewHolder.icon = (ImageView) rowView.findViewById(R.id.notification_icon);
              rowView.setTag(viewHolder);
          }
          else
              viewHolder = (ViewHolder) rowView.getTag();
  
          viewHolder.title.setText(points.get(position).getTitle());
          viewHolder.description.setText(points.get(position).getDescription());
  
          return rowView;
      }
  
      @Override
      public int getCount() {
          return points.size();
      }
  
      private class ViewHolder {
          TextView title;
          TextView description;
          ImageView icon;
      }
  }
  </code></pre>
  
  <p>All ok. BUT! Swipe doesn't work in ViewPager. I think this occurs beacause I return rootView in onCreateView. If I return super.onCreateView(...), swipe works! But list not displayed.</p>
  
  <p>What's wrong?</p>
  
  <p>Thanks.</p>