Bug? xCustomListView ScrollToItem not working

Mike1970

Well-Known Member
Licensed User
Hi, i'm trying to use the scrolltoitem function but when i call it, it doesn't show the last item totally.

ezgif.com-optimize(2).gif


See how the last message isn't displayed totally
 
Last edited:

Mike1970

Well-Known Member
Licensed User
Are you sure that the xCLV is not covered by the keyboard?
Yes, do you see the gap between the Green and the Keyboard? i leaved it to understand exactly this thing.

Non capisco perchè faccia così (I don't understand why it behave like so)
 

LucaMs

Expert
Licensed User
The green part could be also under the keyboard, I cannot know if it is so.
Use Log to know the bottom of the xCLV and top of the keyboard.
 

LucaMs

Expert
Licensed User
Well, I tried right now and ScrollToItem works as expected:

B4X:
For i = 1 To 10
    xCLV.AddTextItem("Item # " & i, i * 11)
Next

xCLV.MultipleSelection = True  ' this in only in a my own custom xCustomListView :D
 
Sleep(1000)
 
xCLV.ScrollToItem(xCLV.Size - 1)
Check the top of your "input box" and the bottom of the xCLV (Logs).
 
Last edited:

Mike1970

Well-Known Member
Licensed User
Well, I tried right now and ScrollToItem works as expected:

B4X:
For i = 1 To 10
    xCLV.AddTextItem("Item # " & i, i * 11)
Next

xCLV.MultipleSelection = True  ' this in only in a my own custom xCustomListView :D
 
Sleep(1000)
 
xCLV.ScrollToItem(xCLV.Size - 1)
Check the top of your "input box" and the bottom of the xCLV (Logs).
Have you tried with the Keyboard open?
I think the problem is with the resize
 

LucaMs

Expert
Licensed User
Have you tried with the Keyboard open?
I think the problem is with the resize
I did it, in a "chat activity".

It is a little complex - I mean its layout (because i use 2 layouts + 1 for items), otherwise I would post the layout and code of the Ime1_HeightChanged event, but it works.

In short, I change the xCLV height according to the new keyboard height and other views:
B4X:
lmxclvChat.AsView.Height = ' ...
Then:

B4X:
lmxclvChat.Base_Resize(lmxclvChat.AsView.Width, lmxclvChat.AsView.Height)

' other stuff

Sleep(10)
If lmxclvChat.Size > 0 Then
    lmxclvChat.JumpToItem(lmxclvChat.Size -1)
End If
Uhm... I used JumpToItem, not ScrollToItem, ma this shound not affect.
 

Mike1970

Well-Known Member
Licensed User
I tried to figure out whats wrong, but i didn't...
I think there is something that isn't working well in the library (@Erel).

I attach the example, you will notice that:
1. JumpToItem / ScrollToItem are working in a strange way (displaying the second-last and not the last one)
2. Drag all the items to the bottom (if the items doesn't fill the visible area)
3. The spacing between items increases if you don't scroll the view (to see the actual last one)

There are weird thing that are going one, i wish to understand if it's my fault or not...
 

Attachments

Mike1970

Well-Known Member
Licensed User
1. The anchors in the layout are not set correctly. You can click on the "Check Anchors" button and see that the views are marked with red color.

2. Why are you calling clv.Base_Resize many times? Why do you need to resize its size at all?

Ok now the anchors are not red anyomore, i deleted a "Base_Resize" i didn't removed it by error. (I tried also with no Base_resize at all).
Nothing changed.
 

Attachments

Filippo

Expert
Licensed User
Hi @Mike1970 ,
change the code from so
B4X:
Sub SendMex(Name As String, Text As String)
    Dim p As Panel
    p.Initialize("p")
    p.Top = 0
    p.Left = 0
    p.Color = Colors.Transparent
    
    Dim m As mex
    m.Name = Name
    m.Text = Text
        
    CustomListView1.Add(p, m)
    AggiustaAltezzaClv
End Sub
to so
B4X:
Sub SendMex(Name As String, Text As String)
    Dim p As Panel
    p.Initialize("p")
    p.Top = 0
    p.Left = 0
    p.Color = Colors.Transparent
    
    Dim m As mex
    m.Name = Name
    m.Text = Text
        
    CustomListView1.Add(p, m)
    CustomListView1.JumpToItem(CustomListView1.Size - 1)
End Sub
 

Mike1970

Well-Known Member
Licensed User
Hi @Mike1970 ,
change the code from so
B4X:
Sub SendMex(Name As String, Text As String)
    Dim p As Panel
    p.Initialize("p")
    p.Top = 0
    p.Left = 0
    p.Color = Colors.Transparent
    
    Dim m As mex
    m.Name = Name
    m.Text = Text
        
    CustomListView1.Add(p, m)
    AggiustaAltezzaClv
End Sub
to so
B4X:
Sub SendMex(Name As String, Text As String)
    Dim p As Panel
    p.Initialize("p")
    p.Top = 0
    p.Left = 0
    p.Color = Colors.Transparent
    
    Dim m As mex
    m.Name = Name
    m.Text = Text
        
    CustomListView1.Add(p, m)
    CustomListView1.JumpToItem(CustomListView1.Size - 1)
End Sub
This is how the code was before writing the function.
Anyway, I will try. Maybe with all the test i’ve done i forget something
 
Top