Getting the index of a clicked item in a list

I want to get the index of the selected item (click) in a ListView.

Can anyone tell me?

Thanks Deepak

+5
source share
2 answers

You need to use AdapterViewits onItemClick method too:

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

Looks like you can get this with ListView1.FocusedItem.Index these days ...

0
source

Source: https://habr.com/ru/post/1757996/


All Articles