title: Creating a ListView inside an ActionBar Tab fragment
body: <p>I'm trying to create a ListView inside an ActionBar tab and can't find a suitable tutorial that can help me create this.</p>
  
  <p>Any sugestions?</p>
  
  <p>Most of the code is already taken out of tutorials, but it results in the following error:</p>
  
  <pre><code>11-25 12:44:29.875: D/libEGL(20751): loaded /system/lib/egl/libEGL_mali.so
  11-25 12:44:29.885: D/libEGL(20751): loaded /system/lib/egl/libGLESv1_CM_mali.so
  11-25 12:44:29.890: D/libEGL(20751): loaded /system/lib/egl/libGLESv2_mali.so
  11-25 12:44:29.895: D/(20751): Device driver API match
  11-25 12:44:29.895: D/(20751): Device driver API version: 10
  11-25 12:44:29.895: D/(20751): User space API version: 10 
  11-25 12:44:29.895: D/(20751): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Tue Oct 16 15:37:13 KST 2012 
  11-25 12:44:29.930: D/OpenGLRenderer(20751): Enabling debug mode 0
  11-25 12:44:30.045: D/AndroidRuntime(20751): Shutting down VM
  11-25 12:44:30.045: W/dalvikvm(20751): threadid=1: thread exiting with uncaught exception (group=0x414fe2a0)
  11-25 12:44:51.650: D/libEGL(21151): loaded /system/lib/egl/libEGL_mali.so
  11-25 12:44:51.660: D/libEGL(21151): loaded /system/lib/egl/libGLESv1_CM_mali.so
  11-25 12:44:51.665: D/libEGL(21151): loaded /system/lib/egl/libGLESv2_mali.so
  11-25 12:44:51.665: D/(21151): Device driver API match
  11-25 12:44:51.665: D/(21151): Device driver API version: 10
  11-25 12:44:51.665: D/(21151): User space API version: 10 
  11-25 12:44:51.665: D/(21151): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Tue Oct 16 15:37:13 KST 2012 
  11-25 12:44:51.695: D/OpenGLRenderer(21151): Enabling debug mode 0
  11-25 12:44:51.865: D/AndroidRuntime(21151): Shutting down VM
  11-25 12:44:51.865: W/dalvikvm(21151): threadid=1: thread exiting with uncaught exception (group=0x414fe2a0)
  11-25 12:44:51.880: E/AndroidRuntime(21151): FATAL EXCEPTION: main
  11-25 12:44:51.880: E/AndroidRuntime(21151): java.lang.RuntimeException: Unable to start activity ComponentInfo{rtd.nightoutin.stellenbosch/rtd.nightoutin.stellenbosch.MainActivity}: java.lang.NullPointerException
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at android.app.ActivityThread.access$600(ActivityThread.java:140)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at android.os.Handler.dispatchMessage(Handler.java:99)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at android.os.Looper.loop(Looper.java:137)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at android.app.ActivityThread.main(ActivityThread.java:4898)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at java.lang.reflect.Method.invokeNative(Native Method)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at java.lang.reflect.Method.invoke(Method.java:511)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at dalvik.system.NativeStart.main(Native Method)
  11-25 12:44:51.880: E/AndroidRuntime(21151): Caused by: java.lang.NullPointerException
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at rtd.nightoutin.stellenbosch.MainActivity.onCreate(MainActivity.java:79)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at android.app.Activity.performCreate(Activity.java:5206)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
  11-25 12:44:51.880: E/AndroidRuntime(21151):    ... 11 more
  11-25 12:44:51.905: D/dalvikvm(21151): GC_CONCURRENT freed 135K, 9% free 12408K/13511K, paused 3ms+2ms, total 23ms
  </code></pre>
  
  <p>I do have separate classes for the Tabs which extends Fragment.</p>
  
  <p>The tabs works 100%, it's only when I try to add the ArrayAdapter and the ListView when it gives me that error.</p>
  
  <p>This is what I have so far.</p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  
  import android.app.ActionBar;
  import android.app.ActionBar.Tab;
  import android.app.ActionBar.TabListener;
  import android.app.FragmentTransaction;
  import android.content.Context;
  import android.os.Bundle;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.view.ViewPager;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  
  public class MainActivity extends FragmentActivity implements TabListener{
  
      private ViewPager viewPager;
      private ActionBar actionBar;
      private TabsPagerAdapter mAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          viewPager = (ViewPager) findViewById(R.id.pager);
          actionBar = getActionBar();
          mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
  
          viewPager.setAdapter(mAdapter);
          actionBar.setDisplayShowTitleEnabled(false);
          actionBar.setDisplayShowHomeEnabled(false);
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
          actionBar.addTab(actionBar.newTab()
                  .setTabListener(this).setIcon(R.drawable.ic_tab_calendar));
          actionBar.addTab(actionBar.newTab()
                          .setTabListener(this).setIcon(R.drawable.ic_tab_favourite));
          actionBar.addTab(actionBar.newTab()
                  .setTabListener(this).setIcon(R.drawable.ic_tab_venue));
  
          viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  
              @Override
              public void onPageSelected(int position) {
                  // on changing the page
                  // make respected tab selected
                  actionBar.setSelectedNavigationItem(position);
              }
  
              @Override
              public void onPageScrolled(int arg0, float arg1, int arg2) {
              }
  
              @Override
              public void onPageScrollStateChanged(int arg0) {
              }
          });
  
          final ListView listview = (ListView) findViewById(R.id.listView_event_by_day);
          String[] values = new String[] { "Android", "iPhone", "WindowsMobile",
              "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X",
              "Linux", "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux",
              "OS/2", "Ubuntu", "Windows7", "Max OS X", "Linux", "OS/2",
              "Android", "iPhone", "WindowsMobile" };
  
          final ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();
          for (int i = 0; i &lt; values.length; ++i) {
            list.add(values[i]);
          }
          final StableArrayAdapter adapter = new StableArrayAdapter(this,
              android.R.layout.simple_list_item_1, list);
          listview.setAdapter(adapter);
      }
  
      @Override
      public void onTabReselected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onTabSelected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
          viewPager.setCurrentItem(tab.getPosition());
      }
  
      @Override
      public void onTabUnselected(Tab tab, FragmentTransaction ft) {
          // TODO Auto-generated method stub
  
      }
  
      private class StableArrayAdapter extends ArrayAdapter&lt;String&gt; {
  
          HashMap&lt;String, Integer&gt; mIdMap = new HashMap&lt;String, Integer&gt;();
  
          public StableArrayAdapter(Context context, int textViewResourceId,
              List&lt;String&gt; objects) {
            super(context, textViewResourceId, objects);
            for (int i = 0; i &lt; objects.size(); ++i) {
              mIdMap.put(objects.get(i), i);
            }
          }
  
          @Override
          public long getItemId(int position) {
            String item = getItem(position);
            return mIdMap.get(item);
          }
  
          @Override
          public boolean hasStableIds() {
            return true;
          }
  
        }
  
  }
  </code></pre>
  
  <p>Any recommendations or tutorials will be greatly appreciated.</p>