Sub GetOpcion2k(Lineas As List ) As ResumableSub
'wrap it with a timed template
Dim Lista As List
Lista.Initialize
Dim Elemento As TD_ListaDuplicados
Dim Cuenta As Long
For Cuenta = 0 To Lineas.Size - 1
Elemento = Lineas.Get(Cuenta)
Lista.Add ((Cuenta + 1) & " º " & Elemento.Producto )
Next
options.Initialize
options.Options = Lista ' Array(Linea1,Linea2)' Array("Cat", "Dog", "Fish", "Crocodile")
options.AllowMultiSelection = False
options.MultiSelectionMinimum = 1
Dim TimedTemplate As B4XTimedTemplate
TimedTemplate.Initialize(options)
TimedTemplate.TimeoutMilliseconds = 30000 'close after 10 seconds (this is the default value)
Wait For (Dialog.ShowTemplate(TimedTemplate, "OK", "", "CANCEL")) Complete (Result As Int)
'If Result = xui.DialogResponse_Positive Then
If options.SelectedItem <> "" Then
'Dialog.Show($"You selected: ${options.SelectedItems}"$, "OK", "", "")
Dim IDLinea As Long
IDLinea = options.SelectedItem.SubString2(0,1)
Return Lineas.Get(IDLinea-1)
Else
Elemento.Initialize
Return Elemento
End If
End Sub
.....
If Lineas.Size > 1 Then
Wait For (GetOpcion2k(Lineas)) Complete (Result As TD_ListaDuplicados)
Else
Result = Lineas.Get(0)
End If
...
'in create activiy:
Dialog.Initialize (Root)
Dialog.Title = "Varios productos"
'and in class_globals:
Sub Class_Globals
Private Dialog As B4XDialog
Private options As B4XListTemplate