tags:

views:

41

answers:

2

Other than using listeners, is there any way by which i can get index of an item in the list?

A: 

indexOf?

Perhaps you mean ListView, in which case you may want getCheckedItemPosition.

Matthew Flaschen
Suppose I have a list having 10 items. When the list control/cursor is in 5th position, I need to get index 5, that too, without using OnItemSelectedListener. is it possible?
mdv
+1  A: 

If you are using 'getCheckedItemPosition' dont forget to set the choice mode to single in order to ensure only one item can be selected at a time. ie via

getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);

And to answer your question : yes , this can be used without a listener.

x1886x
great...thanx a lot!!!
mdv
no problem.Feel free to up-vote if this helped you out ;D
x1886x