title: How to Start Another Activity While Click on List Item?
body: <p>I have created Listview and now want to know how we can start another activity when list view item is clicked ? I really don't know how to do coding further. Please guide me and help me. My coding is ,</p>
  
  <p>MainActivity.Java</p>
  
  <pre><code>package com.topitideas.newlistview;
  
      import android.app.Activity;
      import android.app.ListActivity;
      import android.content.Intent;
      import android.os.Bundle;
      import android.view.Menu;
      import android.view.MenuItem;
      import android.view.View;
      import android.widget.AdapterView;
      import android.widget.AdapterView.OnItemClickListener;
      import android.widget.ArrayAdapter;
      import android.widget.ListAdapter;
      import android.widget.ListView;
      import android.widget.Toast;
  
  
      public class MainActivity extends Activity{
  
          ListView list;
          String[] itemname ={
                  "Safari",
                  "Camera",
                  "Global",
                  "FireFox",
                  "UC Browser",
                  "Android Folder",
                  "VLC Player",
                  "Cold War"
  
          };
  
          Integer[] imgid={
                  R.drawable.pic1,
                  R.drawable.pic2,
                  R.drawable.pic3,
                  R.drawable.pic4,
                  R.drawable.pic5,
                  R.drawable.pic6,
                  R.drawable.pic7,
                  R.drawable.pic8,
  
  
          };
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
  
              CustomListAdapter adapter=new CustomListAdapter(this, itemname, imgid);
              list=(ListView)findViewById(R.id.list);
              list.setAdapter((ListAdapter) adapter);
  
              list.setOnItemClickListener(new OnItemClickListener() {
  
                  @Override
                  public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                                          int position, long id) {
                      // TODO Auto-generated method stub
                      String Slecteditem= itemname[+position];
  
  
                  }
              });
          }
  
  
  
          @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_main, 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_main.xml</p>
  
  <pre><code>&lt;RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"&gt;
  
      &lt;ListView
          android:id="@+id/list"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true" &gt;
      &lt;/ListView&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>CustomListAdapter.java</p>
  
  <pre><code>&gt; package com.topitideas.newlistview;
  &gt; 
  &gt; 
  &gt;         import android.app.Activity;
  &gt;         import android.view.LayoutInflater;
  &gt;         import android.view.View;
  &gt;         import android.view.ViewGroup;
  &gt;         import android.widget.ArrayAdapter;
  &gt;         import android.widget.ImageView;
  &gt;         import android.widget.TextView;
  &gt; 
  &gt; public class CustomListAdapter extends ArrayAdapter&lt;String&gt; {
  &gt; 
  &gt;     private final Activity context;
  &gt;     private final String[] itemname;
  &gt;     private final Integer[] imgid;
  &gt; 
  &gt;     public CustomListAdapter(MainActivity context, String[] itemname, Integer[] imgid) {
  &gt;         super(context, R.layout.mylist, itemname);
  &gt;         // TODO Auto-generated constructor stub
  &gt; 
  &gt;         this.context=context;
  &gt;         this.itemname=itemname;
  &gt;         this.imgid=imgid;
  &gt;     }
  &gt; 
  &gt;     public View getView(int position,View view,ViewGroup parent) {
  &gt;         LayoutInflater inflater=context.getLayoutInflater();
  &gt;         View rowView=inflater.inflate(R.layout.mylist, null,true);
  &gt; 
  &gt;         TextView txtTitle = (TextView) rowView.findViewById(R.id.item);
  &gt;         ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
  &gt;         TextView extratxt = (TextView) rowView.findViewById(R.id.textView1);
  &gt; 
  &gt;         txtTitle.setText(itemname[position]);
  &gt;         imageView.setImageResource(imgid[position]);
  &gt;         extratxt.setText("Description "+itemname[position]);
  &gt;         return rowView;
  &gt; 
  &gt;     }; }
  </code></pre>
  
  <p>mylist.xml </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/icon"
          android:layout_width="60dp"
          android:layout_height="60dp"
          android:padding="5dp" /&gt;
  
      &lt;LinearLayout android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/item"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Medium Text"
              android:textAppearance="?android:attr/textAppearanceMedium"
              android:layout_marginLeft="10dp"
              android:layout_marginTop="5dp"
              android:padding="2dp"
              android:textColor="#33CC33" /&gt;
          &lt;TextView
              android:id="@+id/textView1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="TextView"
              android:layout_marginLeft="10dp"/&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>