iOS Question B4i - xCustomListView - PreoptimizedCLV - Problem

WebQuest

Active Member
Licensed User
Hi Community, I am translating my app from B4a to B4i and since I am not yet familiar with B4i I am experiencing several problems. I have read some posts on xCustomListView and PreoptimizedCLV on B4i but can't seem to resolve. I am using the code from my B4a app which is working correctly. The first thing I did and replicate it on b4i without changes, I don't get any errors but the CustomListView is empty. Anyone know what I need to change in this code?
B4X:
Sub PC1_Init
    PCLV1_View.Initialize(Me, "PCLV1_View", CustomListView1)
    PCLV1_View.ShowScrollBar=False


    For Each word As String In List1
        PCLV1_View.AddItem(100dip, xui.Color_White, word)
    Next
    PCLV1_View.Commit
End Sub

Sub PCLV_HintRequested (Index As Int) As Object
    Dim word As String = CustomListView1.GetValue(Index)
    Return word
End Sub

Sub CustomListView1_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
   
    For Each i As Int In PCLV1_View.VisibleRangeChanged(FirstIndex, LastIndex)
       
        Dim item As CLVItem = CustomListView1.GetRawListItem(i)
        Dim pnl As B4XView = xui.CreatePanel("")
        item.Panel.AddView(pnl, 0, 0, item.Panel.Width,item.Panel.Height)
        'Create the item layout
       
     
    '    ------------------------------------------------
        lblpreis4.Initialize("")
        lblpreis4.SetLayoutAnimated(0,0,0,0,20%x,12%x)
        lblpreis4.TextColor=Colors.RGB(255,92,0)
       
        pnl.LoadLayout("Layout1")
       
        Dim formatter As B4XFormatter
        formatter.Initialize
        formatter.GetDefaultFormat.MaximumFractions = 2
        formatter.GetDefaultFormat.MinimumFractions = 2
        formatter.GetDefaultFormat.Postfix = "€"
       
        For Each d As Double In Array(1, 10, 1000, 1.2)
            LblPrezzo.Text=formatter.Format(Lista2.Get(i))
        Next
   
        LablAnti1.TextColor=Colors.Black
        'LablAnti1.TextSize=16
        'LablAnti1.Typeface=Typeface.DEFAULT_BOLD
        LablAnti1.Text=item.Value
       
        LAnti_desc1.TextColor=Colors.Black
        LAnti_desc1.Text=Lista3.Get(i)
       
        BTAddInOrder.InitializeCustom("BTAddInOrder",Colors.White,Colors.rgb(9,143,255))
        BTAddInOrder.Text=LblPrezzo.Text
       
       
    Next
   
End Sub
 

WebQuest

Active Member
Licensed User
Hi Erel thanks for the quick reply. I tried what you told me.
1- I tested CustomlistView by adding a single panel with the classic AddView method and it works.
2 - I removed the button and the label and loaded only the p.Loadlayout ("Layout1").
3 - LIst1 Contains the data I checked

But still the Customlistviev appears empty
 
Last edited:
Upvote 0

WebQuest

Active Member
Licensed User
OK I solved! List1 was inserted in a function that loaded the list. List1 was empty because the function was called after PC1_Init. The compiler gave no error but did not load anything into the CLV because it had no content to display.
 
Upvote 0
Top