dakairus
dakairus

Reputation: 43

how i get the contact list in multiselect or checklist view?

i need to know how list the contacts of phonebook in a check box list to select more than 1 contact at the same time, because i need it to take the checked phone numbers and send to a multi-contact list sms message

Upvotes: 0

Views: 1932

Answers (2)

Gophermofur
Gophermofur

Reputation: 2101

This is a very broad/long question. I've done this for one of my applications, so I can outline the steps for you and give you pointers.

Getting the Phone Numbers

You'll need to interact with the Contacts API. More specifically, ContactsContract. http://dev.schmid.pro/android/get-contacts-on-android-2-0

How to read contacts on Android 2.0

It's probably best to put the data in an ArrayList.

Displaying

You can use a multi-select listview, which is fairly easy to implement

Or

If you are set on creating a listview with checkboxes, you'll have to create a custom adapter so that you can control the clicking of the checkbox, textview, entire row, etc. http://windrealm.org/tutorials/android/listview-with-checkboxes-without-listactivity.php

Custom adapters are more complex than using the ListView, however, they are powerful and useful and I'd suggest learning them anyways.

Upvotes: 2

xandy
xandy

Reputation: 27421

You don't need a check box list, but a List View with proper setting.

if you set the choiceMode to either multipleChoice or multipleChoiceModal (3.0+) it automatically render the lists items with a check box on right. User getCheckedItemPositions() to access the checked items.

Upvotes: 0

Related Questions