B4J Question [Solved] Fill Short Options List in PreferencesDialog

hwatech

Member
Licensed User
Longtime User
I have really tried to find an answer to this question in the forum but it has eluded me. If there is a posting that explains this, just point me to it...

This is my first app using preferencesdialog, here is a screenshot.



Ultimately, I need to fill the top item (short options) with information from a database, but to make it simple, I just want to fill it programmatically. The item1 text is an Item I put into the FormsBuilder, so my app wouldn't ABEND

Not sure it will help much but here is the section where this dialog is opened and the results processed:

B4X:
Private Sub addrecbtn_Click
    Dim timeinstr As String
    Dim timeoutstr As String
    Dim tottimestr As String
    Dim costcenterstr As String
    Dim summarystr As String
   
    '<<---  Fill Options combo here   --->>
   
    Dim thetime As String
    Wait For (timedialog.ShowDialog(Options1, "Ok", "Cancel")) Complete (Result As Int)
   
    If Result = xui.DialogResponse_Positive Then
        Dim intime As Period = Options1.Get("timein")
        thetime=NumberFormat(intime.Hours,2,0)&":"&NumberFormat(intime.Minutes,2,0)
        timeinstr=utils.ConvertTo12HrTime(thetime,True)

        Dim outtime As Period = Options1.Get("timeout")
        thetime=NumberFormat(outtime.Hours,2,0)&":"&NumberFormat(outtime.Minutes,2,0)
        timeoutstr=utils.ConvertTo12HrTime(thetime,True)
       
        Dim timediff As Period
        DateTime.TimeFormat="hh:mm a"
        timediff= DateUtils.PeriodBetween( DateTime.TimeParse( timeinstr),DateTime.TimeParse(timeoutstr))
        tottimestr=NumberFormat(timediff.Hours,2,0)&":"&NumberFormat(timediff.Minutes,2,0)
       
        costcenterstr=Options1.Get("costcenter")
        summarystr=Options1.Get("summary")
        addrawdataitem(timeinstr,timeoutstr,tottimestr,costcenterstr,summarystr)
    End If
   
End Sub

How to I access the short options item and fill it? I hope I've provided enough information...
 
Last edited:

josejad

Expert
Licensed User
Longtime User
Make a list with the options you want, and then use it to populate the combo:

B4X:
Dim List1 As List
List1.Initialize
List1.AddAll(Array As Int(1, 2, 3, 4, 5)) 

timedialog.SetOptions("CostCenter",List1)  'CostCenter should be the key you've used for your field
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…