B4J Question [B4J] B4XListTemplate font change not working for its CLV?

walt61

Active Member
Licensed User
Longtime User
Attached the test project and the screenshot. The code is just this:
B4X:
    Dim ListTemplate As B4XListTemplate
    Dim dlg As B4XDialog

    dlg.Initialize(MainForm.RootPane)
    dlg.Title = "Title - this is default font 12"
    dlg.TitleBarFont = xui.createDefaultFont(12)
    ListTemplate.Initialize
    ListTemplate.CustomListView1.DesignerLabel.Style = ""
    ListTemplate.CustomListView1.DesignerLabel.Font = fx.DefaultFont(12)
    ListTemplate.Options = Array As String("one", "two", "three", "items - not default font 12")

    Wait For (dlg.ShowTemplate(ListTemplate, "ok", "", "cancel")) Complete (Result As Int)
What am I missing?

test.JPG
 

Attachments

  • test.zip
    2 KB · Views: 53

PaulMeuris

Active Member
Licensed User
It seems that the TitleBarFont is displayed differently. Put line 6 in comment and you will see that the default text font from the title is the same as the font in the CustomListView.
 
Upvote 0

PaulMeuris

Active Member
Licensed User
font size other than 12:
    dlg.Title = "Title - this is default font 10"
    dlg.TitleBarFont = xui.CreateDefaultFont(10)
    ListTemplate.Initialize
    ListTemplate.CustomListView1.DesignerLabel.Style = ""
    ListTemplate.CustomListView1.DesignerLabel.Font = xui.CreateDefaultFont(10)
    ListTemplate.Options = Array As String("one", "two", "three", "items - default font 10")
1676117737809.png

Font size 12 seems to trigger some change in the DesignerLabel.Font. Other font sizes work fine. Strange behavior...
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Another option:

B4X:
Sub Button1_Click

    Dim ListTemplate As B4XListTemplate
    Dim dlg As B4XDialog

    dlg.Initialize(MainForm.RootPane)
    dlg.Title = "Title - this is default font 12"
    dlg.TitleBarFont = xui.createDefaultFont(12)
    ListTemplate.Initialize
    ListTemplate.Options = Array As String("one", "two", "three", "items - default font 12")
   
    Dim RS As ResumableSub = dlg.ShowTemplate(ListTemplate, "ok", "", "cancel")
   
    For i = 0 To ListTemplate.CustomListView1.Size - 1
        Dim P As B4XView = ListTemplate.CustomListView1.GetPanel(i)
        If P.NumberOfViews > 0 Then
            If P.GetView(0) Is Label Then
                Dim L As B4XView = P.GetView(0)
                L.As(Label).Style = ""
                L.Font = xui.createDefaultFont(12)
            End If
        End If
    Next

    Wait For (RS) Complete (Result As Int)


End Sub
 
Upvote 0

walt61

Active Member
Licensed User
Longtime User
font size other than 12:
    dlg.Title = "Title - this is default font 10"
    dlg.TitleBarFont = xui.CreateDefaultFont(10)
    ListTemplate.Initialize
    ListTemplate.CustomListView1.DesignerLabel.Style = ""
    ListTemplate.CustomListView1.DesignerLabel.Font = xui.CreateDefaultFont(10)
    ListTemplate.Options = Array As String("one", "two", "three", "items - default font 10")
View attachment 139154
Font size 12 seems to trigger some change in the DesignerLabel.Font. Other font sizes work fine. Strange behavior...

That's weird indeed - and size 11 works too, it just hates 12 :)
 
Upvote 0

walt61

Active Member
Licensed User
Longtime User
Another option:

B4X:
Sub Button1_Click

    Dim ListTemplate As B4XListTemplate
    Dim dlg As B4XDialog

    dlg.Initialize(MainForm.RootPane)
    dlg.Title = "Title - this is default font 12"
    dlg.TitleBarFont = xui.createDefaultFont(12)
    ListTemplate.Initialize
    ListTemplate.Options = Array As String("one", "two", "three", "items - default font 12")
  
    Dim RS As ResumableSub = dlg.ShowTemplate(ListTemplate, "ok", "", "cancel")
  
    For i = 0 To ListTemplate.CustomListView1.Size - 1
        Dim P As B4XView = ListTemplate.CustomListView1.GetPanel(i)
        If P.NumberOfViews > 0 Then
            If P.GetView(0) Is Label Then
                Dim L As B4XView = P.GetView(0)
                L.As(Label).Style = ""
                L.Font = xui.createDefaultFont(12)
            End If
        End If
    Next

    Wait For (RS) Complete (Result As Int)


End Sub

That one does the trick indeed, thanks Steve !
 
Upvote 0
Top