title: Android: Populate ListView in a fragment
body: <p>I have a activity that fills a ListView, and it is working. Because I use a tabs ViewPager, I have to use fragments instead of activities. So can somebody tell me what I need to change to make a fragment from my activity (FragmentActivity cannot be used in tabs).</p>
  
  <pre><code>package com.basnijkamp.safanagendatest;
  
  import java.util.HashMap;
  import java.util.LinkedList;
  import java.util.List;
  import java.util.Map;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  
  public class ListSample extends Activity {  
  
      public final static String ITEM_TITLE = "title";  
      public final static String ITEM_CAPTION = "caption";  
  
      public Map&lt;String,?&gt; createItem(String title, String caption) {  
          Map&lt;String,String&gt; item = new HashMap&lt;String,String&gt;();  
          item.put(ITEM_TITLE, title);  
          item.put(ITEM_CAPTION, caption);  
          return item;  
      }  
  
      @Override  
      public void onCreate(Bundle icicle) {  
          super.onCreate(icicle);  
  
          List&lt;Map&lt;String,?&gt;&gt; september2012 = new LinkedList&lt;Map&lt;String,?&gt;&gt;();  
          september2012.add(createItem("Electra Mining Africa 2012", "Johannesberg South Africa"));  
          september2012.add(createItem("MSV", "Brno Czech Republic"));  
          september2012.add(createItem("IMTS", "Chicago USA"));
          september2012.add(createItem("AMB", "Stuttgart Germany"));  
          september2012.add(createItem("Den Teknise Messe", "Lillestrom Norway"));  
          september2012.add(createItem("ITM", "Plovdiv Bulgaria"));  
  
          List&lt;Map&lt;String,?&gt;&gt; oktober2012 = new LinkedList&lt;Map&lt;String,?&gt;&gt;();  
          oktober2012.add(createItem("BIMU", "Milan Italy"));  
          oktober2012.add(createItem("Matek", "Istanbul"));
          oktober2012.add(createItem("TIB", "Bucharest Romania"));
          oktober2012.add(createItem("Vienna Tec", "Vienna Austria"));
          oktober2012.add(createItem("Euro Blech 2012", "Hanover Germany"));
          oktober2012.add(createItem("Technica Massan", "Stockholm Sweden"));
  
          List&lt;Map&lt;String,?&gt;&gt; november2012 = new LinkedList&lt;Map&lt;String,?&gt;&gt;();  
          november2012.add(createItem("JIMTOF", "Tokyo Japan"));
          november2012.add(createItem("Metavak", "Gorinchem Netherlands"));
          november2012.add(createItem("FABTECH", "Las Vegas USA"));
          november2012.add(createItem("Prodex", "Basel Switzerland"));
          november2012.add(createItem("EMAF 2012", "Porto Portugal"));
          november2012.add(createItem("Manufact Indonesia", "Jakarta Indonesia"));
  
          // create our list and custom adapter  
          SeparatedListAdapter adapter = new SeparatedListAdapter(this);  
          adapter.addSection("September 2012", new SimpleAdapter(this, september2012, R.layout.list_complex,   
              new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[] { R.id.list_complex_title, R.id.list_complex_caption }));
          adapter.addSection("Oktober 2012", new SimpleAdapter(this, oktober2012, R.layout.list_complex,   
              new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[] { R.id.list_complex_title, R.id.list_complex_caption }));
          adapter.addSection("November 2012", new SimpleAdapter(this, november2012, R.layout.list_complex,   
                  new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[] { R.id.list_complex_title, R.id.list_complex_caption }));
  
          ListView list = new ListView(this);  
          list.setAdapter(adapter);  
          this.setContentView(list);  
  
      }  
  
  }  
  </code></pre>
  
  <p>Thanks in advance</p>