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: 2
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I was wondering why this bug only appears with a certain number of items, and I finally figured out at least this!

The item that opens/closes has a certain height; if the sum of the heights of the title bars of subsequent items is greater than that height, the problem won't be noticed, but it still persists.

Here the sum of 3-4-5-6 is greater than the expandable part of item #2, so you don't see the expandable panel of item #2 and you "think" that there is no error.
java_w3g4ASzBVl.gif


Same project. The sum of the heights of headers 4 and 5 is less than the height of the expandable panel in item 3.
java_TpE5wEkef1.gif



This happens because the panel is animated immediately and the scrolling does not occur during that animation but at the end of it.
 
Upvote 0

pixet

Active Member
Licensed User
Longtime User
What I could see by slowing down the animation is that it creates the (landing) panel for the clicked item and adds the space (of the next closed item) where the last item will land after the animation. Is this the action you mean?
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
What I could see by slowing down the animation is that it creates the (landing) panel for the clicked item and adds the space (of the next closed item) where the last item will land after the animation. Is this the action you mean?
The expandable part of the clicked element is immediately and fully displayed (I believe it's just a copy), and only then does the movement begin, the scrolling of the subsequent items.
These two things should instead be aligned; the expandable panel should gradually increase in height (appear) WHILE the other items are moved/scrolled.
 
Upvote 0
Top