Deepak
Deepak

Reputation: 473

getting the index of clicked item in a listview

I want to get the index of the Selected Item ( Clicked ) in a ListView.

Can any one please tell me?

Thanks Deepak

Upvotes: 6

Views: 7797

Answers (1)

Sephy
Sephy

Reputation: 50392

You need to use an AdapterView and its onItemClick method :

lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    public void onItemClick(AdapterView<?> list, View v, int pos, long id) {
        yourAdapter.getItem(pos);           
    }
});

Upvotes: 11

Related Questions