title: Cannot cast 'android.view.View' to 'com.example.shabeer.listview.ListView'
body: <p>I get an error in this line here </p>
  
  <p><code>list_view = (ListView)findViewById(R.id.listView_id);</code> shows error</p>
  
  <blockquote>
    <p>inconvertible type; cannot cast android.view.View to
    com.example.shabeer.listview.ListView</p>
  </blockquote>
  
  <p>also the <code>list_view.setAdapter(adapter);</code> is not working.</p>
  
  <p>ListView class:</p>
  
  <pre><code>package com.example.shabeer.listview;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.ArrayAdapter;
  
  public class ListView extends AppCompatActivity {
  
      public static ListView list_view;
      private static String[] NAMES = new String[] { "Tom", "John", "Jack", "Pal"};
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_list_view);
      }
  
      public void listView(){
           list_view = (ListView)findViewById(R.id.listView_id);
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.name_list, NAMES);
          list_view.setAdapter(adapter);
      }
  
  
      @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_view, 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);
      }
  }
  </code></pre>
  
  <p>activity_list_view.xml:</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:orientation="vertical"
      android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".ListView"&gt;
  
  
      &lt;ListView
          android:id="@+id/listView_id"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>AndroidManifect.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.shabeer.listview" &gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name=".ListView"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>