title: How to write method for listView with android:Onclick="listViewMetod" in its layout?
body: <p>I am trying to create 5 buttons in my main activity and am trying to put new activities in them.</p>
  <p>In the fifth button, I am having a problem with listView.</p>
  <p>In the below code, am I missing anything required for the listView(View v) method to work properly?</p>
  <p>Here is my code:</p>
  <p>listActivity.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  android:layout_width=&quot;fill_parent&quot;
  android:layout_height=&quot;fill_parent&quot;
  android:orientation=&quot;vertical&quot; &gt;
  
  &lt;ListView
      android:id=&quot;@+id/listView1&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot; &gt;
  &lt;/ListView&gt;
     
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>main.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  android:layout_width=&quot;fill_parent&quot;
  android:layout_height=&quot;fill_parent&quot;
  android:orientation=&quot;vertical&quot; &gt;
  
  &lt;TextView
      android:layout_width=&quot;fill_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:text=&quot;@string/hello&quot; /&gt;
  
  &lt;Button
      android:id=&quot;@+id/button1&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:onClick=&quot;newActivity&quot;
      android:text=&quot;Yeni Aktivite&quot; /&gt;
  
  &lt;Button
      android:id=&quot;@+id/button2&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:onClick=&quot;toast&quot;
      android:text=&quot;Toast&quot; /&gt;
  
  &lt;Button
      android:id=&quot;@+id/button3&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:onClick=&quot;web&quot;
      android:text=&quot;Web&quot; /&gt;
  
  &lt;Button
      android:id=&quot;@+id/button4&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:onClick=&quot;preferences&quot;
      android:text=&quot;Preferences&quot; /&gt;
  
  &lt;Button
      android:id=&quot;@+id/button5&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:onClick=&quot;listVieww&quot;
      android:text=&quot;ListView&quot; /&gt;
  
    &lt;/LinearLayout&gt;
  </code></pre>
  <p>Main activity</p>
  <pre><code>package com.uygulamalar.odev;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.ListView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class OdevKarmaActivity extends Activity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);        
      }
  
      public void newActivity(View v) {
          Intent intent = new Intent(getApplicationContext(), NewActivity.class);
          startActivity(intent);
      }
  
      public void toast(View v) {
          Toast toast=Toast.makeText(getApplicationContext(), &quot;vazzupp&quot;, 9999);
          toast.show();
      }
  
      public void listVieww(View v) {
          ListView listView1;
          String jedigiller[] = {&quot;pelin&quot;,&quot;figen&quot;,&quot;aylin&quot;,&quot;gizem&quot;};
      
          listView1=(ListView) findViewById(R.id.listView1);
          listView1.setAdapter(new
                  ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1 , jedigiller));
      }
  }
  </code></pre>
  <p>When run, the code forces the Android emulator to close.</p>
  <p>I am suspecting that the issue is related to the listView(View v) method, did I miss anything when using it?</p>