mdv
mdv

Reputation: 499

Getting list item index

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

Upvotes: 0

Views: 1001

Answers (2)

x1886x
x1886x

Reputation: 1227

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.

Upvotes: 2

Matthew Flaschen
Matthew Flaschen

Reputation: 284786

indexOf?

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

Upvotes: 1

Related Questions