title: How to set OnClickListener in Listview to send to another activity
body: <p>I'm making a android app that uses listview,  I have problem where to put OnClickListener in the listview that I created in order to go to another activity but I haven't found a solution. Here is my code.</p>
  
  <p><strong>CuacaNowActivity.java</strong></p>
  
  <pre><code>public class CuacaNowActivity extends Activity {
  
  protected void onCreate(Bundle savedInstanceState) {
  
      ListView listViewKab;
  
      super.onCreate(savedInstanceState);
      setTitle("Jogja Now");
      setContentView(R.layout.cuacanow);
  
      KabupatenNow weather_data[] = new KabupatenNow[]{
          new KabupatenNow(R.drawable.ic_bantul, "Bantul"),
          new KabupatenNow(R.drawable.ic_gunungkidul, "Wonosari"),
          new KabupatenNow(R.drawable.ic_kulonprogo, "Wates"),
          new KabupatenNow(R.drawable.ic_sleman, "Sleman"),
          new KabupatenNow(R.drawable.ic_yogyakarta, "Yogyakarta")
      };
  
      KabupatenAdapter adapter = new KabupatenAdapter(this, R.layout.listkabupaten_row, weather_data);
      listViewKab = (ListView) findViewById(R.id.listViewKab);
      View header = (View) getLayoutInflater().inflate(R.layout.listviewheader, null);
      listViewKab.addHeaderView(header);
      listViewKab.setAdapter(adapter);
  }
  }
  </code></pre>
  
  <p><strong>KabupatenAdapter.java</strong></p>
  
  <pre><code>public class KabupatenAdapter extends ArrayAdapter&lt;KabupatenNow&gt;{
  Context context;
  int layoutResourceId;
      KabupatenNow data[] = null;
      public KabupatenAdapter(Context context, int layoutResourceId, KabupatenNow[] data) {
          super (context, layoutResourceId, data);
          this.layoutResourceId = layoutResourceId;
          this.context = context;
          this.data = data;
      }
  
      //Viewing list Kabupaten in Yogyakarta with image in ListView
      public View getView (int position, View convertView, ViewGroup parent){
          View row = convertView;
          WeatherHolder holder = null;
  
          if (row == null)
          {
              LayoutInflater inflater = ((Activity)context).getLayoutInflater();
              row = inflater.inflate(layoutResourceId, parent, false);
  
              holder = new WeatherHolder();
              holder.imgKabupaten = (ImageView) row.findViewById(R.id.imgKabupaten);
              holder.txtTitle = (TextView) row.findViewById(R.id.txtTitle);
  
              row.setTag(holder);
          }else{
              holder = (WeatherHolder) row.getTag();
          }
  
          KabupatenNow weather = data[position];
          holder.txtTitle.setText(weather.title);
          holder.imgKabupaten.setImageResource(weather.icon);
          return row;
      }
  
      static class WeatherHolder {
          ImageView imgKabupaten;
          TextView txtTitle;
      }
  }
  </code></pre>
  
  <p><strong>KabupatenNow</strong></p>
  
  <pre><code>public class KabupatenNow {
  
          public int icon;
          public String title;
          public KabupatenNow(){
              super();
          }
  
          public KabupatenNow(int icon, String title) {
              super();
              this.icon = icon;
              this.title = title;
          }
  }
  </code></pre>
  
  <p>and here is the xml code</p>
  
  <p><strong>cuacanow.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/ic_background"
  android:orientation="vertical" &gt;
  
  &lt;ListView
      android:id="@+id/listViewKab"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:cacheColorHint="#00000000" &gt;
  &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>listviewheader.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="horizontal" &gt;
  
  &lt;TextView
      android:id="@+id/txtHeader"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_alignParentBottom="true"
      android:layout_alignParentTop="true"
      android:background="#8B0000"
      android:gravity="center_vertical"
      android:padding="10dp"
      android:text="Cuaca Kabupaten"
      android:textColor="#FFFFFF"
      android:textSize="22dp"
      android:textStyle="bold" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>listkabupaten_row.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="horizontal" &gt;
  
  &lt;ImageView
      android:id="@+id/imgKabupaten"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:layout_alignParentBottom="true"
      android:layout_alignParentTop="true"
      android:layout_marginBottom="5dp"
      android:layout_marginRight="15dp"
      android:layout_marginTop="5dp"
      android:gravity="center_vertical" /&gt;
  
  &lt;TextView
      android:id="@+id/txtTitle"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_alignParentBottom="true"
      android:layout_alignParentTop="true"
      android:layout_marginBottom="5dp"
      android:layout_marginTop="5dp"
      android:gravity="center_vertical"
      android:textColor="#000000"
      android:textSize="22dp"
      android:textStyle="bold" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>listview is work properly, but what I want is when I click on menu Bantul it will go to BantulActivity as well as Wonosari and others. Can I implement my project like that? Or maybe any suggestion for my project?</p>