title: Getting a nullpointerexception here for things I don't understand
body: <p>EDIT: I moved everything to OnCreateView as you guys said but now  I get the errors that "my listView is non-static field cannot be referenced to static  (same for getApplication()" and that "ArrayAdapter cant be resolved as constructor" </p>
  
  <p>So I want to make a listView in my activity with fragment and I implemented the following code from a tutorial. It doesn't show me where the error is and I don't know exactly which object or thing is null.</p>
  
  <pre><code>package com.example.aland.intrigueme;
  
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v7.app.ActionBarActivity;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.Toast;
  
  
  public class listActivity extends ActionBarActivity {
  
  
      ListView listView;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_list);
          if (savedInstanceState == null) {
              getSupportFragmentManager().beginTransaction()
                      .add(R.id.container, new PlaceholderFragment())
                      .commit();
          }
  
          //haal listView van XML
          listView = (ListView) findViewById(R.id.list);
  
          //waarden in Array definiëren om lijst te tonen
  
          String[] values = new String[] {"Park","Café","Nachtclub","Straat","School/Opleiding"};
  
          // Definieert nieuwe Adapter
          // Eerste paramater = context
          // Tweede parameter = layout voor rijen
          // Derde parameter = ID voor de textView
          // Vierde = data array
  
          ArrayAdapter &lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
                  android.R.layout.simple_list_item_1,android.R.id.text1, values);
  
          //Adapter instellen aan lijst
          listView.setAdapter(adapter);
  
          //onClick event voor lijst
          listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
  
                  //listview clicked item index
                  int itemPosition = position;
  
                  //listview clicked item value
                  String itemValue = (String) listView.getItemAtPosition(position);
  
                  //show alert
                  Toast.makeText(getApplicationContext(),
                          "Position: "+itemPosition+" Listitem: " +itemValue, Toast.LENGTH_LONG).show();
  
  
              }
          });
  
  
      }
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_list, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      /**
       * A placeholder fragment containing a simple view.
       */
      public static class PlaceholderFragment extends Fragment {
  
          public PlaceholderFragment() {
          }
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
              View rootView = inflater.inflate(R.layout.fragment_list, container, false);
              return rootView;
          }
      }
  }
  </code></pre>
  
  <p>This is my XML file </p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
      android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin"
      tools:context="com.example.aland.intrigueme.listActivity$PlaceholderFragment"&gt;
  
      &lt;ListView android:layout_width="match_parent"
          android:layout_height="fill_parent"
          android:id="@+id/list" /&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and this is the error I get</p>
  
  <pre><code>01-17 19:02:43.080    2830-2830/com.example.aland.intrigueme E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: com.example.aland.intrigueme, PID: 2830
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.aland.intrigueme/com.example.aland.intrigueme.listActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
              at android.app.ActivityThread.access$800(ActivityThread.java:144)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
              at com.example.aland.intrigueme.listActivity.onCreate(listActivity.java:49)
              at android.app.Activity.performCreate(Activity.java:5933)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
              at android.app.ActivityThread.access$800(ActivityThread.java:144)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  01-17 19:03:50.460    2830-2830/com.example.aland.intrigueme I/Process﹕ Sending signal. PID: 2830 SIG: 9
  01-17 19:04:16.630    2870-2870/com.example.aland.intrigueme D/AndroidRuntime﹕ Shutting down VM
  01-17 19:04:16.630    2870-2870/com.example.aland.intrigueme E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: com.example.aland.intrigueme, PID: 2870
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.aland.intrigueme/com.example.aland.intrigueme.listActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
              at android.app.ActivityThread.access$800(ActivityThread.java:144)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
              at com.example.aland.intrigueme.listActivity.onCreate(listActivity.java:49)
              at android.app.Activity.performCreate(Activity.java:5933)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
              at android.app.ActivityThread.access$800(ActivityThread.java:144)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  01-17 19:04:19.400    2870-2870/com.example.aland.intrigueme I/Process﹕ Sending signal. PID: 2870 SIG: 9
  </code></pre>