Contact list with multiple phone numbers

anaylor01

Well-Known Member
Licensed User
Longtime User
What I am trying to do is when the user clicks on a contact on a listview and if that contact has multiple phone numbers it opens a messagebox with all the numbers listed with radio buttons to select which number the user wants to call. My question is how do I get the multiple numbers associated with the contact the user selected. I have done the contacts list sorted in a list view at this this:
http://www.b4x.com/forum/basic4android-updates-questions/7857-contact-phone-number-chooser.html
 

anaylor01

Well-Known Member
Licensed User
Longtime User
The below code is what I am using to get a list of contacts. I want to be able to use it to get the email address and if the contact has more than one number of the contact the user selects from the listview. Any help?

B4X:
    Dim map1 As Map
    map1.Initialize
    Dim list1 As List
    list1.Initialize
    For i = 0 To listOfContacts.Size - 1
        myContact = listOfContacts.Get(i)
        list1.Add(myContact.DisplayName)
        map1.Put(myContact.DisplayName, myContact,mycontact.EMAIL_HOME)
    Next
    list1.Sort(True)
    For i = 0 To list1.Size - 1
        myContact = map1.Get(list1.Get(i))
        lvcontacts.AddSingleLine(myContact.DisplayName)
    Next
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Instead of using AddSingleLine you should use AddSingleLine2 and add myContact as the second parameter.
Later when the user presses on an item the value passed to ItemClick will be the contact object:
B4X:
Sub lvContacts_ItemClick(Position As Int, Value As Object)
 Dim c As Contact
 c = Value
 Dim phones As Map
 phones = c.GetPhones
 For i = 0 to phones.size - 1
  Dim p As String
  p = phones.GetKeyAt(i)
  ... work with the phone number
 Next
End Sub
 
Upvote 0
Top