Using ContactUtils I list the contacts and the user selects a contact which gives him a list of phone numbers for that contact. Here's the relevant code. In the first sub I list the contacts. In the second sub I list the phone numbers for the selected contact (from the first sub) if there are any. If there aren't any phone numbers the second sub displays a blank in the "listPhonenums" display view. Instead of a blank I would like to display a message "No phone number(s) for this contact. How can I code to test if a contact has any phone numbers?
B4X:
Sub GetContacts
Dim allContacts As List = cu.FindAllContacts(True)
allContacts.SortTypeCaseInsensitive("DisplayName", True)
For Each c As cuContact In allContacts
listContactsview.AddSingleLine2(c.DisplayName, c)
Next
End Sub
Sub listContactsview_ItemClick (Position As Int, Value As Object)
Dim c As cuContact = Value
listPhonenums.Clear
For Each phone As cuPhone In cu.GetPhones(c.Id)
listPhonenums.AddSingleLine(phone.Number & " , " & phone.PhoneType)
Next
End Sub