Private Sub Input_DB(title As String, fieldnames As List, fieldvalues As List, hints As List, labelwidth As Int) As Int
' Multiple line input dialog. Uses Lib 'Dialogs' by Andrew Graham
' Dimension of Lists has to be equal or at least that of 'Labels'
' This SUB is modal. No global variables or additional SUBs are necessary. It will return
' the original ret value of CustomDialog. Values are changed only if "yes"/"OK" button is pressed.
' Please adapt the Button Texts of CustomDialog as you need them
' Use Labelwidth to vary the relation between prompts/labels and EditTexts. 10-90. 50 means equal.
'It will Return DialogResponse.POSITIVE If the OK Button was pressed, AND the Values List updated with the new entries, otherwise remain unchanged.
'Labelwidth (from 0 To 90, like %) Is used To balance the Label width with the EditText. 50 means equal width For both.
Dim returnw As Int
Dim cd As CustomDialog
Dim scv As ScrollView
Dim NumberofItems,i As Int
Dim lwidth,ewidth As Int
NumberofItems = fieldnames.Size
labelwidth=Min(90,Max(labelwidth,0)) 'labelwidth can be 0
scv.Initialize((NumberofItems+0)*50dip)
lwidth = (90%x*labelwidth/100-6)*1dip
ewidth = (90%x*(1-labelwidth/100)-10)*1dip
scv.Color = Colors.DarkGray
Dim InLabel(NumberofItems) As Label
For i=0 To NumberofItems-1
InLabel(i).Initialize(""): InLabel(i).TextSize = 14
InLabel(i).Gravity=Gravity.CENTER_VERTICAL
InLabel(i).Text = fieldnames.Get(i)
scv.Panel.AddView(InLabel(i),5dip,i*50dip,lwidth,48dip)
Next
Dim MuEditInputs(NumberofItems) As EditText
For i=0 To NumberofItems-1
MuEditInputs(i).Initialize("")
MuEditInputs(i).SingleLine=True 'single line
MuEditInputs(i).Text = fieldvalues.Get(i)
MuEditInputs(i).Hint = hints.Get(i): MuEditInputs(i).HintColor = Colors.LightGray
scv.Panel.AddView(MuEditInputs(i),lwidth+10dip,i*50dip+2dip,ewidth,50dip)
Next
cd.AddView(scv,0,0,90%x,Min(90%y-100dip,i*50dip)) ' sizing relative to the screen size is probably best -100dip
returnw = cd.Show(title,"OK","Cancel","",Icon)
If returnw = DialogResponse.POSITIVE Then '
For i=0 To MuEditInputs.Length-1
fieldvalues.Set(i, MuEditInputs(i).Text)
Next
End If
Return returnw
End Sub