Android Question Select phone# from listview using ContactUtils - - Solved

Startup

Active Member
Licensed User
Longtime User
I want the user to be able to select a contact from the list of contacts and then select a phone number from the selected contact's list of phone numbers. So I added this code to Erel's ContactUtils code to create the list of phone numbers for the contact

For Each phone As cuPhone In cu.GetPhones(c.Id)
sbp.Append(phone.Number & ", " & phone.PhoneType).Append(CRLF)
Next
lstPhonenums.AddSingleLine2(sbp.ToString,phone.Number)

and then I added this sub to allow the user to select from the contact's list of phone numbers generated from the above sub

Sub lstPhonenums_ItemClick (Position As Int, Value As Object)
lblPhonenum.Text=""
lblPhonenum.Text=Value
End Sub

However when the user clicks on the first phone number in the list (lstPhonenums) the second of the two numbers appears in the labelview (lblPhonenum). How can I get the first number selectable?

Attached is the complete code zipped.
 

Attachments

  • ContactUtilsTest.zip
    11.1 KB · Views: 183

Startup

Active Member
Licensed User
Longtime User
I want the user to be able to select a contact from the list of contacts and then select a phone number from the selected contact's list of phone numbers. So I added this code to Erel's ContactUtils code to create the list of phone numbers for the contact

For Each phone As cuPhone In cu.GetPhones(c.Id)
sbp.Append(phone.Number & ", " & phone.PhoneType).Append(CRLF)
Next
lstPhonenums.AddSingleLine2(sbp.ToString,phone.Number)

and then I added this sub to allow the user to select from the contact's list of phone numbers generated from the above sub

Sub lstPhonenums_ItemClick (Position As Int, Value As Object)
lblPhonenum.Text=""
lblPhonenum.Text=Value
End Sub

However when the user clicks on the first phone number in the list (lstPhonenums) the second of the two numbers appears in the labelview (lblPhonenum). How can I get the first number selectable?

Attached is the complete code zipped.

Solved. I changed the first code paragraph above to

For Each phone As cuPhone In cu.GetPhones(c.Id)
lstPhonenums.AddSingleLine(phone.Number)
Next

which works fine

Is there a way to remove a question if you've solved it? Hate to waste anybody's time reading my long question!
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Is there a way to remove a question if you've solved it? Hate to waste anybody's time reading my long question!

2 things... 1. use code tags when posting code .. easier to read. [code] paste / insert code here [/code]

2. just edit the thread title .. ie [Solved] Select phone#from etc etc ... right hand side, just below thread title "Thread Tools"
do not delete it as someone else may encounter the same problem .. and you have wisely posted the solution.
 
Upvote 0

Startup

Active Member
Licensed User
Longtime User
2 things... 1. use code tags when posting code .. easier to read. [code] paste / insert code here [/code]

2. just edit the thread title .. ie [Solved] Select phone#from etc etc ... right hand side, just below thread title "Thread Tools"
do not delete it as someone else may encounter the same problem .. and you have wisely posted the solution.

Ok. Will do. Thanks mangojack!
 
Upvote 0
Top