This method will be called when an item in the list is selected. (short-pressed)
1. Bind ArrayAdapter to ListView
2. In the MainActivity.java file, add the following imports.
import android.widget.ListView;
import android.view.View;
3. Then add the following method after the onCreate method.
import android.widget.ListView;
import android.view.View;
//l: The ListView where the click happened
//v: The item that was selected with the ListView
//position: The position of the selected item in the list
//id: The row ID of the item that was selected
//v: The item that was selected with the ListView
//position: The position of the selected item in the list
//id: The row ID of the item that was selected
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
}
4. Add your action in the onListItemClick method. To test it, add a toast with the below message.
"ListView: " + l + " View: " + v + " List Position: " + position + " RowID: " + id
http://developer.android.com/reference/android/app/ListActivity.html#onListItemClick(android.widget.ListView, android.view.View, int, long)