Android Question Expandable list screen not refreshed properly after an item is deleted

toby

Well-Known Member
Licensed User
Longtime User
I've made some small changes to the expandable list tutorial code so that I could achieve a simple task: delete the most recently expanded item.

Unfortunately the item(s) below the deleted item wouldn't move up to occupy the entire space freed, just the collapsed item height instead. The attached screenshot shows what the screen looks like after item 3 was deleted.

B4X:
Sub Button1_Click
    Log("Number of items before: " & clv1.Size)
    clv1.RemoveAt(ExpandedIndex) 'ExpandedIndex keeps track of most recently expanded item
    Log("Number of items after: " & clv1.Size)
End Sub

What am I missing? sample code also attached.

Thank you very much in advance for your helps!

Season's greetings!

toby
 

Attachments

  • B4a.expandable list problem.jpg
    B4a.expandable list problem.jpg
    168.9 KB · Views: 165
  • expandableList.zip
    9.5 KB · Views: 163

klaus

Expert
Licensed User
Longtime User
Add CollapseItem(ExpandedIndex) before clv1.RemoveAt(ExpandedIndex).
B4X:
Sub Button1_Click
    Log("Number of items before: " & clv1.Size)
    CollapseItem(ExpandedIndex)
    clv1.RemoveAt(ExpandedIndex)
    Log("Number of items after: " & clv1.Size)
End Sub
 
Upvote 0
Top