Question: i have a listview like this

```
companyname              symbol

samsung                  sam
onida                    ond
tata                     ta
.                         .
.                         .
.                         .

```

so i want to get the index of the selected item and also string of the selected item(i.e.,sam(or)ond(or)ta) .So please tell me how to get the index of the selected item and string also .

Thank you in advance

Answer: 
use this way

```
listview.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() 
{
    public void onItemSelected(AdapterView parentView, View childView, int position, long id) 
    {
        String text = ((TextView)childView.getText()).toString();
        //The above text variable has the text value of selected item
        // position will reflect the index of selected item
    }
    public void onNothingSelected(AdapterView parentView) 
    {
    }
});

```
I would prefer implementing the activity as a ListActivity and override the onListItemClick method:

```
@override
protected void onListItemClick(ListView l, View v, int position, long id)

```

this gives you the position of the item clicked (I hope this is what you call index).