setSelection on a listView in a dialogBox

18 views
Skip to first unread message

sahir contractor

unread,
Mar 30, 2011, 9:16:13 PM3/30/11
to Purdue Android Programming
hi guys,
so i have a dialogBox that pops up with a listView that allows
multiple selection. what im trying to do is have certain of the
entries in the listView be automatically selected ( by which i mean
the little tick mark at the right should be selected when the list
comes up) ... i have literally tried every possible variant of
setSelection including even something called PostDelayed which i was
told would run after a certain delay and then select items for me but
none of them seem to be working ...
any help will be seriously appreciated.
thank you,
Sahir.

Rodrigo Haragutchi

unread,
Mar 31, 2011, 12:42:07 PM3/31/11
to purdue-androi...@googlegroups.com, sahir contractor
is there a reason why you're using listView inside a dialog? If you're ok with just text for each item, you can look at this:

the line just above "creating a ProgressDialog"

Quote:
The second parameter in the setSingleChoiceItems() method is an integer value for the checkedItem, which indicates the zero-based list position of the default selected item. Use "-1" to indicate that no item should be selected by default.
--
Rodrigo Haragutchi
Purdue ACM SigApp President
Google Student Ambassador

sahir contractor

unread,
Apr 9, 2011, 9:01:38 PM4/9/11
to Purdue Android Programming
well i guess the reason im using the listView is because im already in
a dialog box and dont want to spawn another dialog for this list.
So if i have to work with this list view that allows multiple
selection, is there a way to have certain values selected during
startup.
Thanks
Sahir.
Reply all
Reply to author
Forward
0 new messages