Reputation: 519
I am working on an android 2.2 app. When clicking a button I would like to display a list with checkboxes with all the contact persons from the list. After checking the persons from the list I want to display the phone numbers of the persons from the list. I don't know how to do that.
I don't know how to display in a listview with checkboxes all the contact persons from a list. Need some help.
This is my code for the ocntact list:
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
if (requestCode == PICK_CONTACT)
{
Cursor cursor = managedQuery(intent.getData(), null, null, null, null);
cursor.moveToNext();
String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
String name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
Toast.makeText(this, "Contect LIST = "+name, Toast.LENGTH_LONG).show();
}
}//onActivityResult
}
How to put all the contact name and phone numbers in a listview with checkboxes and than when ok is pressed to save all the checked persons in a list or a vector?
Upvotes: 1
Views: 2257
Reputation: 2278
this link must help you
http://www.vogella.de/articles/AndroidListView/article.html
UPDATE1: after:
holder.checkbox.setChecked(list.get(position).isSelected());
write:
if (holder.checkbox.isChecked()){
Log.i("LOG", "check box " + list.get(position).getName() + " is checked");
} else {
Log.i("LOG", "check box " + list.get(position).getName() + " is not checked");
}
Upvotes: 1
Reputation: 182
Well...i guess that the element from the list contains a checkbox and a text view.
You could add another text view to this element for the phone number and set it gone. Then checkbox should be set to listen for clicks, and when it is checked, set some text in the phone number text view and make it visible.
Hope this helps.
Upvotes: 0
Reputation: 1129
This Might Help You...
http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/
Upvotes: 0