B4J Question [SOLVED] Customlistview jumptoitem issue

rosippc64a

Active Member
Licensed User
Longtime User
Hi All!
I have a customlistview. On the screen there are 5 items visible.
before.png


I add a new item, and jumptoitem(5), but the last row remain below the visible area:
after.png

How can I make it visible programatically?
 

Jorge M A

Well-Known Member
Licensed User
Longtime User
It is a little difficult to help without seeing some segment of your code, but you can try the .ScrollToItem() method
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
Thank you, @Jorge M A, you are right, here is the solution: I move the jumptoitem to other code fragment and works!
I use separate code to fill items.
B4X:
Sub FilterSearch As ResumableSub
    Dim lasti As Int = CLVItemList.Size
    CLVItemList.Clear
    For Each ID As sItemData In formSzamlaMain.sList
        Dim lID As sItemData = ID
        Dim Pnl As B4XView = xui.CreatePanel("")
        Pnl.SetLayoutAnimated(0, 0, 0, CLVItemList.AsView.Width, 100dip)
        If CLVItemList.Size = lasti Then
            ID.Tag = 10
        Else
            ID.Tag = 0
        End If
        CLVItemList.Add(Pnl, lID)
    Next
    frmszamlacikkek.Title = $" ${CLVItemList.Size} SZÁMLÁZOTT TERMÉKEK"$   
    CLVItemList.sv.Visible = True
    'If CLVItemList.Size > 0 Then
        'CLVItemList.JumpToItem(lasti)    <--------------------- doesn't work here
    '    Sleep(0)
    'End If
    Return True
End Sub
And this for display items:
B4X:
Sub CLVItemList_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
    Dim ExtraSize As Int = 25 'List size
    For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, CLVItemList.Size - 1)
        Dim Pnl As B4XView = CLVItemList.GetPanel(i)
        If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
            If Pnl.NumberOfViews = 0 Then 'Add each item/layout to the list/main layout
                Dim ID As sItemData = CLVItemList.GetValue(i)
                Pnl.LoadLayout("szamlasor")
                txtMenny.Text = ID.menny
                txtBruttoar.Text = ID.BruttoAr
                LblMegnevezes.Text = ID.megnevezes
                lblAFA.Text = ID.afa
                lblMe.Text = ID.ME
                If IsNumber(ID.Tag) And 10 = ID.Tag Then
                    txtMenny.RequestFocus       
                    CLVItemList.JumpToItem(lasti) '<-------------- does work here
                End If
            End If
        Else 'Not visible
            If Pnl.NumberOfViews > 0 Then
                Pnl.RemoveAllViews 'Remove none visible item/layouts from the list/main layout
            End If
        End If
    Next
End Sub
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
use:

 
Upvote 0
Top