iOS Question Day selection for B4i and B4A

Nitin Joshi

Active Member
Licensed User
Longtime User
How do i pop up a list of week days (Monday to Sunday) and user should able to select day(s) as require.
For example, when we set the alarm by clicking Repeat, a list of pops up and user can select days(s). I have attached iOS pictures for the reference.

I am looking for a solution supporting B4i and B4A both.

Thank you.
 

Attachments

  • Image 1.jpeg
    25.5 KB · Views: 89
  • Image 2.jpeg
    23.5 KB · Views: 84
Solution
You can set the SelectedItems before showing the dialog and they will be selected:
B4X:
listtemplate.Options = Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
    Dim sf As Object = dialog.ShowTemplate(listtemplate, "Ok", "", "Cancel")
listtemplate.SelectedItems = Array("Sunday", "Tuesday") '<-----
Dim sf As Object = dialog.ShowTemplate(listtemplate, "Ok", "", "Cancel")

Nitin Joshi

Active Member
Licensed User
Longtime User
Dear Erel, thank you very much for the suggestion.
May i further request additional support with some example or link to learn? I have never used B4XDialog + B4XListTemplate.

Thank you very much for your support as always.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4XDialog is explained here: https://www.b4x.com/android/forum/threads/b4x-input-dialogs-with-xui-views.101197/#content
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private dialog As B4XDialog
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    dialog.Initialize(Root)
End Sub

Private Sub Button1_Click
    Dim listtemplate As B4XListTemplate
    listtemplate.Initialize
    listtemplate.AllowMultiSelection = True
    listtemplate.MultiSelectionMinimum = 1
    listtemplate.Options = Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
    Dim sf As Object = dialog.ShowTemplate(listtemplate, "Ok", "", "Cancel")
    Wait For (sf) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Log(listtemplate.SelectedItems)
    End If
End Sub

And styling options: https://www.b4x.com/android/forum/threads/b4x-share-your-b4xdialog-templates-theming-code.131243/
 
Upvote 0

Nitin Joshi

Active Member
Licensed User
Longtime User
As the list pops up I want some days to be highlighted/selected. How can i achieve this. I could not find option for it.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can set the SelectedItems before showing the dialog and they will be selected:
B4X:
listtemplate.Options = Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
    Dim sf As Object = dialog.ShowTemplate(listtemplate, "Ok", "", "Cancel")
listtemplate.SelectedItems = Array("Sunday", "Tuesday") '<-----
Dim sf As Object = dialog.ShowTemplate(listtemplate, "Ok", "", "Cancel")
 
Upvote 0
Solution

Nitin Joshi

Active Member
Licensed User
Longtime User
listtemplate.Options = Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
@Erel , i want to index each object of the list so i used following code. In B4i, it works fine but in B4A, it throws error (screenshot attached). What could be the reason?

list code:
listtemplate.Options.Set(0, "Sunday")
listtemplate.Options.Set(1, "Monday")
listtemplate.Options.Set(2, "Tueday")
listtemplate.Options.Set(3, "Wednesday")
listtemplate.Options.Set(4, "Thursay")
listtemplate.Options.Set(5, "Friday")
listtemplate.Options.Set(6, "Saturday")

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…