Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim ContactList As List
Dim NameSearch As AutoCompleteEditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
ContactList.Initialize
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub SearchContact(s As String)
Dim Contacts2 As Contacts2
Dim listOfContacts As List
listOfContacts = Contacts2.FindByName(s, False, True, False) 'No need Note
For i = 0 To listOfContacts.Size - 1
Dim Contact As Contact
Contact = listOfContacts.Get(i)
Dim phones As Map
phones = Contact.GetPhones ' Get all the phone numbers
If phones.Size > 0 Then
For j = 0 To phones.Size - 1
ContactList.Add(Contact.DisplayName & " (" & phones.GetKeyAt(j) & ")") ' To display like: Santa Clause (0011223344)
Next
End If
Next
NameSearch.SetItems(ContactList)
End Sub
Sub Name_ItemClick (Value As String)
ToastMessageShow(Value, False) ' Error?
End Sub
Sub Name_TextChanged (Old As String, New As String)
ContactList.Clear 'Clear list before search
SearchContact(New)
End Sub