Android Code Snippet [B4X] Share your B4XDialog + templates theming code

Guenter Becker

Active Member
Licensed User
View attachment 166948

B4X:
Private Sub SetLightThemeListTemplate(Dialog1 As B4XDialog, ListTemplate1 As B4XListTemplate)
    Dim TextColor As Int = 0xFF5B5B5B
    Dialog1.BackgroundColor = xui.Color_White
    Dialog1.ButtonsColor = xui.Color_White
    Dialog1.BorderColor = xui.Color_Gray
    Dialog1.ButtonsTextColor = 0xFF007DC3
    ListTemplate1.CustomListView1.sv.ScrollViewInnerPanel.Color = 0xFFDFDFDF
    ListTemplate1.CustomListView1.sv.Color = Dialog.BackgroundColor
    ListTemplate1.CustomListView1.DefaultTextBackgroundColor = xui.Color_White
    ListTemplate1.CustomListView1.DefaultTextColor = TextColor
    Dialog.OverlayColor = xui.Color_Transparent
End Sub

Usage example:
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private ListTemplate As B4XListTemplate
    Private Dialog As B4XDialog
End Sub

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

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    Dialog.Initialize(Root)
    ListTemplate.Initialize
    SetLightThemeListTemplate(Dialog, ListTemplate)
End Sub

Private Sub Button1_Click
    ListTemplate.Options = Array("Item 1", "Item 2", "Item 3")
    Dim rs As Object = Dialog.ShowTemplate(ListTemplate, "", "", "Cancel")
    Wait For (rs) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Log(ListTemplate.SelectedItem)
    End If
End Sub
Thank you Erel that works fine
 
Top