title: ArrayAdapter Android without Context
body: <p>I want to implement an <code>ArrayAdapter</code> in my class which extends <code>Fragment</code> not <code>Activity</code>.</p>
  
  <p>The problem is what to pass in the first parameter of the constructor of ArrayAdapter.</p>
  
  <pre><code>ArrayAdapter&lt;String&gt; myAdapter = new ArrayAdapter&lt;String&gt;(&lt;what place here&gt;,android.R.layout.simple_list_item1,anyarraylist);
  </code></pre>
  
  <p>Now what should i do with the first parameter? I tried to pass       </p>
  
  <pre><code>getActivity().getApplicationContext()
  </code></pre>
  
  <p>in the first parameter but the code crashed.</p>
  
  <p>Please help me out.</p>
  
  <p>My logcat:</p>
  
  <pre><code>03-17 03:33:08.029: E/AndroidRuntime(596): FATAL EXCEPTION: main
  03-17 03:33:08.029: E/AndroidRuntime(596): java.lang.NullPointerException
  03-17 03:33:08.029: E/AndroidRuntime(596):  at com.search.pages.SearchResults.onCreateView(SearchResults.java:92)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:871)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:420)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at android.os.Handler.handleCallback(Handler.java:587)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at android.os.Handler.dispatchMessage(Handler.java:92)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at android.os.Looper.loop(Looper.java:123)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at android.app.ActivityThread.main(ActivityThread.java:4627)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at java.lang.reflect.Method.invokeNative(Native Method)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at java.lang.reflect.Method.invoke(Method.java:521)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  03-17 03:33:08.029: E/AndroidRuntime(596):  at dalvik.system.NativeStart.main(Native Method)
  </code></pre>