When the dialog appears, I want to highlight the second item with different text color and/or background color, Unfortunately the following code doesn't work for me. Could someone kindly show me how to achieve that, please?
Unable to highlight the preselected item:
Dim options As B4XListTemplate
options.Initialize
options.Options = Array("Cat", "Dog", "Fish", "Crocodile")
options.SelectedItem="Dog" '<==preselect second item
options.SelectionColor=xui.Color_Magenta 'show it in different color
Wait For (Dialog.ShowTemplate(options, "OK", "", "CANCEL")) Complete (Result As Int)
If Result = xui.DialogResponse_Positive Then
Dialog.Show($"You selected: ${options.SelectedItem}"$, "OK", "", "")
End If
This will take care of you Toby, without changing library
B4X:
Dim options As B4XListTemplate
options.Initialize
options.Options = Array("Cat", "Dog", "Fish", "Crocodile")
Dim rs As ResumableSub =Dialog.ShowTemplate(options, "OK", "", "CANCEL")
options.SelectedItem = options.Options.Get(1)
options.SelectionColor=xui.Color_Magenta
options.CustomListView1.GetPanel(1).Color = options.SelectionColor
wait for (rs) Complete (Result As Int)
If Result = xui.DialogResponse_Positive Then
Dialog.Show($"You selected: ${options.SelectedItem}"$, "OK", "", "")
End If
This will take care of you Toby, without changing library
B4X:
Dim options As B4XListTemplate
options.Initialize
options.Options = Array("Cat", "Dog", "Fish", "Crocodile")
Dim rs As ResumableSub =Dialog.ShowTemplate(options, "OK", "", "CANCEL")
options.SelectedItem = options.Options.Get(1)
options.SelectionColor=xui.Color_Magenta
options.CustomListView1.GetPanel(1).Color = options.SelectionColor
wait for (rs) Complete (Result As Int)
If Result = xui.DialogResponse_Positive Then
Dialog.Show($"You selected: ${options.SelectedItem}"$, "OK", "", "")
End If