B4J Question CLVExpandable

LucaMs

Expert
Licensed User
Longtime User
Something isn't working properly.

I tried for hours :confused: , even with the help of Copilot, without being able to solve the problem.
Until I realized that the example project attached to the thread:
https://www.b4x.com/android/forum/t...g-or-collapsing-xcustomlistview-items.106148/
has the same problem.

The project works fine if the number of items is 20:
java_e2HfWAbma7.gif


which is the value in the project. If you change it to 2, 3, 4, or probably any other number, the bug you see in the animated GIF appears (I intentionally slowed down the animation just to highlight the bug):
java_OUVudwuwrk.gif
 

pixet

Active Member
Licensed User
Longtime User
I tried to solve it this way:
I added an "If" in the CLVExpandable.bas module in the "Sub ResizeItem" to check if I'm on the last "Item."

B4X:
'mod's by Pixet
' verifica se è l'ultimo item
'    'forza scroll all'ultimo Item' --> mCLV.ScrollToItem(mCLV.Size-1)
    If Index = (mCLV.Size -1) Then
        ' se l'ultimo item
        'scrool up and show item
        mCLV.ScrollToItem(mCLV.Size-1)
    End If
You can create both an entry and exit animation for the last item by adding a "Pane" above the last item with the same background color as the mCLV and then, in a loop/for/next, resize it, reducing its size, making it disappear and thus removing it from the mCLV.
 

Attachments

  • CLVExpandable-pixet..zip
    5.5 KB · Views: 0
Upvote 0
Top