title: list view makes android app crash
body: <p>I am working on a health related android app. In this, I am using floating action button in IndexPage.java to switch to another activity FoodEntry.java(having listview for food items). In this whenever we click on floating button app crashes. One thing i found out is that app is crashing due to listview. Please help me to find solution of it.</p>
  
  <p>This is IndexPage.java</p>
  
  <pre><code>public class IndexPage extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_index_page);
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
      fab.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
             Intent in = new Intent(IndexPage.this, FoodEntry.class);
              startActivity(in);
  
          }
      });
  }
  }
  </code></pre>
  
  <p>FoodEntry.java</p>
  
  <pre><code>public class FoodEntry extends AppCompatActivity {
  
  // Array of strings...
  String[] food = {"Naan","Pav bhaji","chole tikiya", "rice", "soyabean", "milk", "curd", "abc", "def", "dfadf", "fasdfa", "fsadf", "fdsfa", "fga"};
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
  
      ArrayAdapter adapter = new ArrayAdapter&lt;&gt;(this, R.layout.activity_item, food);
      ListView listViewFoodItems = (ListView)findViewById(R.id.listViewFood);
      listViewFoodItems.setAdapter(adapter);
  } }
  </code></pre>
  
  <p>Error on logcat</p>
  
  <pre><code>03-31 15:30:58.555 13732-13732/com.praval.healthfreak W/dalvikvm: threadid=1: calling UncaughtExceptionHandler
  03-31 15:30:58.556 13732-13732/com.praval.healthfreak E/AndroidRuntime: FATAL EXCEPTION: main
                                                                          Process: com.praval.healthfreak, PID: 13732
                                                                          java.lang.RuntimeException: Unable to start activity ComponentInfo{com.praval.healthfreak/com.praval.healthfreak.FoodEntry}: java.lang.NullPointerException
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2389)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441)
                                                                              at android.app.ActivityThread.access$900(ActivityThread.java:151)
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
                                                                              at android.os.Handler.dispatchMessage(Handler.java:110)
                                                                              at android.os.Looper.loop(Looper.java:193)
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5345)
                                                                              at java.lang.reflect.Method.invokeNative(Native Method)
                                                                              at java.lang.reflect.Method.invoke(Method.java:515)
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
                                                                              at dalvik.system.NativeStart.main(Native Method)
                                                                           Caused by: java.lang.NullPointerException
                                                                              at com.praval.healthfreak.FoodEntry.onCreate(FoodEntry.java:20)
                                                                              at android.app.Activity.performCreate(Activity.java:5343)
                                                                              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
                                                                              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2343)
                                                                              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2441) 
                                                                              at android.app.ActivityThread.access$900(ActivityThread.java:151) 
                                                                              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354) 
                                                                              at android.os.Handler.dispatchMessage(Handler.java:110) 
                                                                              at android.os.Looper.loop(Looper.java:193) 
                                                                              at android.app.ActivityThread.main(ActivityThread.java:5345) 
                                                                              at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                              at java.lang.reflect.Method.invoke(Method.java:515) 
                                                                              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828) 
                                                                              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644) 
                                                                              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>