0
list = (ListView) findViewById( R.id.simple_list );
    String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars",
            "Jupiter", "Saturn", "Uranus", "Neptune"};
    ArrayList<String> planetList = new ArrayList<String>();
    planetList.addAll( Arrays.asList(planets) );

    // Create ArrayAdapter using the planet list.
    listAdapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.food_menu, planetList);



    // Set the ArrayAdapter as the ListView's adapter.
   list.setAdapter( listAdapter );

the error is on the bottom line it says

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.grantjones20.restaurant/com.example.grantjones20.restaurant.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference

Benjamin
  • 7,055
  • 6
  • 40
  • 60
  • 1
    `findViewById( R.id.simple_list )` is returning null. You've not provided enough information for us to be able to determine exactly why. Please look into how to create a [mcve]. – Mike M. Mar 20 '18 at 14:05
  • you din't initialized list – Venky G Mar 20 '18 at 14:08

0 Answers0