title: Applying Spinner set adapter in fragment cause NullPointerException
body: <p>I have some problem in set adapter to spinner in fragment , it keep cause NullPointerException
  I have no idea what's going on , please help thanks</p>
  
  <pre><code>public class GradeFragment extends ListFragment {
  
      private static final String[] LIST = { "102-1", "102-2","103-1","103-2" };
  
      List&lt;String&gt; list = new ArrayList&lt;String&gt;();
      private Spinner spinner;
  
      @Override    
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
          View view = inflater.inflate(R.layout.listview, container, false);
          spinner = (Spinner) view.findViewById(R.id.spinner);
          ArrayAdapter&lt;String&gt; arrayadapter = new ArrayAdapter&lt;String&gt;(
                  getActivity().getApplicationContext(),
                  android.R.layout.simple_spinner_item, list);
          arrayadapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          spinner.setAdapter(arrayadapter);
          spinner.setPrompt("select");
          spinner.setOnItemSelectedListener(new SpinnerSelectedListener());
          return view;
      }
  
      public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
      }
  
      class SpinnerSelectedListener implements OnItemSelectedListener {    
  
          public void onItemSelected(AdapterView&lt;?&gt; parents, View v, int position, long arg3) {
              String str = parents.getItemAtPosition(position).toString();
          }
  
          public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
          }
      }
  }
  </code></pre>
  
  <p><strong>spinner</strong>:</p>
  
  <pre><code>&lt;Spinner
    android:id="@+id/spinner"
    android:layout_width="wrap_content"
    android:layout_height="40dip"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" /&gt;
  </code></pre>
  
  <p>Log:</p>
  
  <pre><code>05-10 23:21:16.316: E/AndroidRuntime(2436): FATAL EXCEPTION: main 
  05-10 23:21:16.316: E/AndroidRuntime(2436): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.grade/com.example.grade.MainActivity}: android.view.InflateException: Binary XML file line #63: Error inflating class fragment 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.ActivityThread.access$600(ActivityThread.java:141) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.os.Handler.dispatchMessage(Handler.java:99) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.os.Looper.loop(Looper.java:137) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.ActivityThread.main(ActivityThread.java:5041) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at java.lang.reflect.Method.invokeNative(Native Method) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at java.lang.reflect.Method.invoke(Method.java:511) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at dalvik.system.NativeStart.main(Native Method) 
  05-10 23:21:16.316: E/AndroidRuntime(2436): Caused by: android.view.InflateException: Binary XML file line #63: Error inflating class fragment 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at com.example.grade.InFragment.onCreateView(InFragment.java:14) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.Fragment.performCreateView(Fragment.java:1695) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:861)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1137)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.Activity.onCreateView(Activity.java:4717) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.Activity.setContentView(Activity.java:1881) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at com.example.grade.MainActivity.onCreate(MainActivity.java:12) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.Activity.performCreate(Activity.java:5104) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     ... 11 more 
  05-10 23:21:16.316: E/AndroidRuntime(2436): Caused by: java.lang.NullPointerException 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at com.example.grade.GradeFragment.onCreateView(GradeFragment.java:77)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.Fragment.performCreateView(Fragment.java:1695) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:861)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1137)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.app.Activity.onCreateView(Activity.java:4717) 
  05-10 23:21:16.316: E/AndroidRuntime(2436):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
  05-10 23:21:16.316: E/AndroidRuntime(2436):     ... 31 more
  </code></pre>