The attached test app is based on the CustomListView with floating titles example with lazy loading applied. All appear to be working correctly. For demo purpose, the list is very short.
Now I want to incorporate the hide/show item code (mainly calling ResizeItem function) which has been tested on a regular CustomListView. In this test app. I try to hide all items containing text "2" and they are indeed hidden as expected. However, as shown in the attached screenshot, there is a space gap (which is a little taller than an item height) at the hidden item location. If I scroll the list up and down, the gap would increase. The CLV height and number of items remain unchanged all the times. Could someone kindly enough to tell me what I did wrong, please?
there is a space gap (which is a little taller than an item height) at the hidden item location. If I scroll the list up and down, the gap would increase
The space is reclaimed. I am not sure if this solves your ultimate problem. I am not too knowledgeable on xCLV to predict unwanted consequences by doing that, but it worked here. Also, when you have long lists, the scrolling becomes jerkey.
The space is reclaimed. I am not sure if this solves your ultimate problem. I am not too knowledgeable on xCLV to predict unwanted consequences by doing that, but it worked here. Also, when you have long lists, the scrolling becomes jerkey.
It will remove the item permanently, not suitable for my particular application.
My new solution is
1. Add a B4XFloatTextField
2. Move the code related to show/hide items from clv1_VisiableRangeChanged() to B4XFloatTextField_TextChanged().
Toby: I tried your new project with the B4XFloatTextField_TextChanged().. For 4 or 5 items list it is ok, Try it For i = 0 To 40, and then search for 3 for instance, you will see all kind of gaps and erratic display. Something is still not kosher.
I also noticed that it's not reliable and I'm looking for a different and better approach by pointing to the first matching item without hiding anything.
I can think of possibly 2 solutions that may solve your situation, unless you have already figured it out:
1. Option 1: Using a SQLite database for the data and use an edittext or B4XFloatTextField to enter your search string and based on the edtSearchBox_TextChanged (Old As String, New As String, filter the outoutput using the LIKE operator in SQLite: exple: LIKE '%${New}%' to search on either side of the columns data. Youcan still use xCLV to display the data.
2. Option 2; Go the route of B4XTable which has a built-in powerful search feature that can filter your output, but it is horizontally page based rather than vertically scrolled xCLV
I also noticed that it's not reliable and I'm looking for a different and better approach by pointing to the first matching item without hiding anything.
Instead of hiding/unhiding CLV items, you may jump to found item using clv.ScrollToItem() like this;
B4X:
private pos as int = 0 'this is global variable to store found position of clv item, so that we may start searching again from the last found item to onwards...
Private srch as string
private found as boolean = false
For i = pos To clv.Size - 1
srch = clv.GetValue(i) ' this value is the same which you added while creating CLV Items...
If srch.Contains(txtSearchTerm.Text) Then
clv.ScrollToItem(i)
found = True
pos = i + 1
Exit
End If
Next