title: Attempt to invoke virtual method 'void android.widget.ListView.setAdapter(android.widget.ListAdapter)' on a null object reference
body: <p>I am getting this error. mostly error i checked getting a erro about null object  refernce</p>
  
  <pre><code>public class MainActivity extends Activity {
  
       //SQLiteOpenHelper sqLiteOpenHelper;
      //SQLiteDatabase sqLiteDatabase;
        String[] mobileArray = {"Android","IPhone","WindowsMobile","Blackberry","WebOS","Ubuntu","Windows7","Max OS X"};
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          final ArrayAdapter&lt;String&gt; adapter;
          adapter=new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_2,mobileArray);
          ListView mylistView= (ListView) findViewById(R.id.listView1);
          mylistView.setAdapter(adapter);
  
      }
  }
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <p>here is the main.xml file</p>
  
  <p>
  
  <pre><code>          xmlns:tools="http://schemas.android.com/tools"
  
            android:layout_width="match_parent"
  
            android:layout_height="match_parent"
  
            tools:context="com.example.myapplication5.app.MainActivity"
  
            android:orientation="vertical"&gt;
  
  &lt;android.support.v7.widget.Toolbar
  
          android:id="@+id/toolbar"
  
          android:layout_width="match_parent"
  
          android:layout_height="attr/actionBarSize"
  
          android:background="attr/colorPrimary"/&gt; 
  &lt;ListView
          android:layout_width="match_parent"
  
          android:layout_height="wrap_content"
  
  
          android:id="@+id/listView1" /&gt;
  
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>this is the listview through which the adapter is connected</p>