title: android null pointer exception setting adapter for custom list on fragment
body: <p>I have a project with fragments working ok, im using actionbarsherlock, and sliding menu by jeremyfeinstein,</p>
  
  <p>all is working fine,
  but when I want to customize the left drawer list cells, i get an exception </p>
  
  <blockquote>
    <p>NullPointerException</p>
  </blockquote>
  
  <p>here my code,</p>
  
  <p>for showing the left table working fine on basic mode for list , simple_list_item_1</p>
  
  <p>but when I customize it, I get the exception,</p>
  
  <p>here the list [PhoneMenuList.java]:</p>
  
  <pre><code> public class PhoneMenuList extends SherlockListFragment{
  
   public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
  
      return super.onCreateView(inflater, container, savedInstanceState);  
  
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState){
      super.onActivityCreated(savedInstanceState);
  
      //SET THE LIST ADAPTER!
  
      Hamburger hambu_data[] = new Hamburger[]
              {
                  new Hamburger(R.drawable.icon_hambu_folder, "My Documents"),
                  new Hamburger(R.drawable.icon_hambu_favs, "Top 10 viewed"),
                  new Hamburger(R.drawable.icon_hambu_validate, "Validate"),
                  new Hamburger(R.drawable.icon_hambu_how, "How to use"),
                  new Hamburger(R.drawable.icon_hambu_how, "About")
              };              
  
  
  
  
          ListView productList= (ListView) getActivity().findViewById(R.id.listView1);
  
        //for context!
          HamburgerAdapter adapter = new HamburgerAdapter(getActivity(), R.layout.hamburger_item_row, hambu_data);            
  
  
          /*
          View header = (View)getLayoutInflater(savedInstanceState).inflate(R.layout.hamburger_item_row, null);
          productList.addHeaderView(header);
  
  
          productList.setAdapter(adapter);
  
          */       
  } 
   }
  </code></pre>
  
  <p>on list.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ListView xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/listView1"
  
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:divider="#000000"
      android:dividerHeight="1dip" /&gt;
  </code></pre>
  
  <p>hamburguer item row</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="horizontal" 
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:padding="10dp"&gt;
  
       &lt;ImageView android:id="@+id/imgIcon"
          android:layout_width="wrap_content"
          android:layout_height="fill_parent"
          android:gravity="center_vertical"
          android:layout_alignParentTop="true"
          android:layout_alignParentBottom="true"
          android:layout_marginRight="15dp"
          android:layout_marginTop="5dp"
          android:layout_marginBottom="5dp" /&gt;
  
       &lt;TextView android:id="@+id/txtTitle"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:gravity="center_vertical"
          android:layout_alignParentTop="true"
          android:layout_alignParentBottom="true"
          android:textStyle="bold"
          android:textSize="22dp"
          android:textColor="#000000"
          android:layout_marginTop="5dp"
          android:layout_marginBottom="5dp" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>so how to fix the exception when i set my adapter</p>
  
  <blockquote>
    <p>productList.setAdapter(adapter);</p>
  </blockquote>
  
  <p>Thanks!</p>
  
  <p>edit 1</p>
  
  <p>HamburgerAdapter.java</p>
  
  <pre><code>public class HamburgerAdapter extends ArrayAdapter&lt;Hamburger&gt;{
  
      Context context; 
      int layoutResourceId;    
      Hamburger data[] = null;
  
  
      public HamburgerAdapter(Context context, int layoutResourceId, Hamburger[] data) {
          super(context, layoutResourceId, data);
  
          this.layoutResourceId = layoutResourceId;
          this.context = context;
          this.data = data;
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          View row = convertView;
          WeatherHolder holder = null;
  
          if(row == null)
          {
              //inflater for fragment!
  
              LayoutInflater inflater = ((Activity)context).getLayoutInflater();
  
  
  
              row = inflater.inflate(layoutResourceId, parent, false);
  
              holder = new WeatherHolder();
              holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
              holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);
  
              row.setTag(holder);
          }
          else
          {
              holder = (WeatherHolder)row.getTag();
          }
  
          Hamburger hamburger = data[position];
          holder.txtTitle.setText(hamburger.title);
          holder.imgIcon.setImageResource(hamburger.icon);
  
          return row;
      }
  
      static class WeatherHolder
      {
          ImageView imgIcon;
          TextView txtTitle;
      }
  
  }
  </code></pre>
  
  <p>edit 2,</p>
  
  <p>Exception , when using:</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
  
     // return super.onCreateView(inflater, container, savedInstanceState);  
  
      View mView = inflater.inflate(R.layout.list, container, false);
      return mView; 
  }
  
  01-01 11:43:27.110: W/dalvikvm(14502): threadid=1: thread exiting with uncaught exception (group=0x410292a0)
  01-01 11:43:27.110: E/AndroidRuntime(14502): FATAL EXCEPTION: main
  01-01 11:43:27.110: E/AndroidRuntime(14502): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.chocolate.tiks_documents/com.chocolate.tiks_documents.MainActivityPhone}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.app.ActivityThread.access$600(ActivityThread.java:140)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.os.Handler.dispatchMessage(Handler.java:99)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.os.Looper.loop(Looper.java:137)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.app.ActivityThread.main(ActivityThread.java:4898)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at java.lang.reflect.Method.invokeNative(Native Method)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at java.lang.reflect.Method.invoke(Method.java:511)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at dalvik.system.NativeStart.main(Native Method)
  01-01 11:43:27.110: E/AndroidRuntime(14502): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.support.v4.app.ListFragment.ensureList(ListFragment.java:344)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.support.v4.app.ListFragment.onViewCreated(ListFragment.java:145)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:941)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:556)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1167)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.app.Activity.performStart(Activity.java:5216)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2073)
  01-01 11:43:27.110: E/AndroidRuntime(14502):    ... 11 more
  </code></pre>