B4J Question B4XViews - Question from a newborn newbie

LucaMs

Expert
Licensed User
Longtime User
P.S. Forget it; it WAS a very stupid question 😄



B4X: Copy
Private Sub clvResult_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
    mCLVTree.CLV_VisibleRangeChanged(FirstIndex, LastIndex)

    For i = FirstIndex To LastIndex
        Dim pnl As B4XView = clvResult.GetPanel(i)

        'Works
        Dim k As Int
        For Each xView As B4XView In pnl.GetAllViewsRecursive
            Log(k & " " & GetType(xView))
            If k = 5 Then
                If i Mod 2 = 0 Then
                    xView.TextColor = xui.Color_Yellow
                End If
            End If
            k = k + 1
        Next
     
        >>>>>>>>> ISN'T THIS THE SAME THING? It crashes:
        'java.lang.IndexOutOfBoundsException: Index 5 out of bounds for length 1
        pnl.GetView(5).TextColor = xui.Color_Yellow
     
        clvResult.ResizeItem(i, 35dip)
    Next
End Sub
 
Last edited:
Could be as pnl only contains one item -> Dim pnl As B4XView = clvResult.GetPanel(i) << only item i is in the pnl

May work if you use clvResult in place of pnl in pnl.GetView(5).TextColor = xui.Color_Yellow
 
Upvote 0
I don't see it is same.


Are you sure pnl has at least 6 child views?

Are you trying to make alternate colors?
Never mind! My mistake (fortunately temporary; my two neurons are currently still working - A LITTLE BIT) was believing that `k` pointed to the label I was looking for, without considering that it increased with every "depth level change."

I explained it poorly; I'm counting on your neurons 😁
 
Upvote 0
Back
Top