B4J Question [SOLVED] B4xDialog CLV change item high

Tomtom2

New Member
Licensed User
Hello,
i try to change the high of the items in a xCustomListView witch is shown in B4XDialog.
As template i use „B4XListTemplate“.

In the example I try to replace the items of the customListView with the replaceAt Functon after Button Clicked, but it wil not work.


B4X:
Sub Button1_Click

    ' change the font high in the customListView   
    #if B4J
    options.CustomListView1.DesignerLabel.Style = ""
    #End If
    Dim l As B4XView = options.CustomListView1.DesignerLabel
    l.Font =xui.CreateDefaultFont(10)
    
    ' ######                                                                                                                       #######
    ' ###### Here I try to replace the Items in the CustomListView. But this not work  #######
    '
    Dim clv As CustomListView = options.CustomListView1
    If options.CustomListView1.Size > 0 Then ' only for test at first run the clv is empty   
        
        ' change all items in clv
        For i=0 To clv.Size-1
            Dim pnl As B4XView  = clv.GetPanel(i)
            
            ' For Debug check the Views
            For Each v As B4XView In pnl.GetAllViewsRecursive
                Log ("The View items:  " & GetType(v))
                    If v Is Label Then
                End If
            Next
            ' Replace with high="80"
            clv.ReplaceAt(i,pnl,80,"nothing")
        Next
    
    End If

    Wait For (Dialog.ShowTemplate(options, "OK", "", "CANCEL")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Dialog.Show($"You selected: ${options.SelectedItems}"$, "OK", "", "")
    End If
End Sub
 

Attachments

  • DialogTest_CustomView_Resize.zip
    2.7 KB · Views: 212

TILogistic

Expert
Licensed User
Longtime User
?
Dim rs As ResumableSub = Dialog.ShowTemplate(options, "OK", "", "CANCEL")
B4X:
Sub Button1_Click

    
    ' change the font high in the customListView
    #if B4J
    options.CustomListView1.DesignerLabel.Style = ""
    #End If
    
    Dim rs As ResumableSub =  Dialog.ShowTemplate(options, "OK", "", "CANCEL")
    
    Dim l As B4XView = options.CustomListView1.DesignerLabel
    l.Font =xui.CreateDefaultFont(10)
    
    
    ' ######                                                                          #######
    ' ###### Here I try to replace the Items in the CustomListView. But this not work  #######
    '

    Dim clv As CustomListView = options.CustomListView1
    Log(options.CustomListView1.Size)
    
    If options.CustomListView1.Size > 0 Then ' only for test at first run the clv is empty
        
        ' change all items in clv
        For i=0 To clv.Size-1
            Dim pnl As B4XView  = clv.GetPanel(i)
            
            ' For Debug check the Views
            For Each v As B4XView In pnl.GetAllViewsRecursive
                Log ("The View items:  " & GetType(v))
                If v Is Label Then
                End If
            Next
        
            clv.ReplaceAt(i,pnl,80,"nothing")
        Next
    
    End If

    Wait For (rs) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Dialog.Show($"You selected: ${options.SelectedItems}"$, "OK", "", "")
    End If
End Sub

 
Upvote 0

Tomtom2

New Member
Licensed User
Hi @Omar Parra A. ,
my problem is the height of the items of the listview. I want change the current height value to, for example, 40dip.

Is this possible when i use "Dialog.ShowTemplate" ?

As a solution i try it with "Dialog.ShowCustom" and Custom Layouts that will work.
 
Upvote 0

Tomtom2

New Member
Licensed User
That works fine for me.
@Omar Parra A. : Thanks !

I don t know why i did not use this function before.
After changing the height alignment of the Text in the Item is not "CENTER". it is necessary t change the label too.
Here ist the current Funrction

B4X:
Sub Button1_Click

    ' change the font high in the customListView   
    #if B4J
    options.CustomListView1.DesignerLabel.Style = ""

    #End If
    Dim l As B4XView = options.CustomListView1.DesignerLabel
    l.Font =xui.CreateDefaultFont(12)
    
    ' change the height of the items and the label
    Dim rs As ResumableSub =  Dialog.ShowTemplate(options, "OK", "", "CANCEL")
    
    Dim clv As CustomListView = options.CustomListView1
        ' run over all items
        For i=0 To clv.Size-1
            Dim pnl As B4XView  = clv.GetPanel(i)
            For Each v As B4XView In pnl.GetAllViewsRecursive
                    ' If Type Label change the height of this.
                    If v Is Label Then
                        Dim label As B4XView = v.As(Label)
                        label.Height=35        ' change height of label
                End If
            Next
        clv.ResizeItem(i,30) ' change height of item
        Next

    Wait For (rs) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Dialog.Show($"You selected: ${options.SelectedItems}"$, "OK", "", "")
    End If
End Sub
 

Attachments

  • Resize_item_io.png
    7.5 KB · Views: 186
  • Resize_item_an_label_io.png
    7.9 KB · Views: 210
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…