Android Question SearchTemplate Many elements

red30

Well-Known Member
Licensed User
Longtime User
B4X:
SearchTemplate.SetItems(Items)
If I use many elements (100-1000) for the SearchTemplate, then I have to wait more than 100ms. Is it possible to somehow speed up this process? Also, the time depends on different devices, the older the device, the longer the list is displayed.
I've used Spinner for a lot of elements, but Spinner doesn't have the convenience of searching like SearchTemplate. Is it possible to add search to Spinner somehow?
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

stevel05

Expert
Licensed User
Longtime User
As DonManfred says, 100ms is pretty quick. Also, are you testing it in release mode?
 
Upvote 0

MikeSW17

Active Member
Licensed User
Longtime User
Frankly, the user won't notice a 0.1s delay.
Obviously, less powerful devices (older) will be slower.
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
As DonManfred says, 100ms is pretty quick. Also, are you testing it in release mode?
Yes, I tested this on a mod release. Yes, you're right, 100ms is not enough. But visually it looks like the program freezes and then displays the list. If I load an array with more than 1000 elements, this time will increase to 1s on old devices.
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
Don't call SetItems immediately before showing the list. Call it after the layout is loaded (add Sleep(100) in between).
This is a solution, but my list may change after the layout is loaded. It also does not solve the problem when I need to substitute different lists in the SearchTemplate during the program execution ...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Building the index of a large list takes time and it needs to be done properly if the lists are large.

You will note that you can store the generated index and set the items with SetIndex. This will be very fast and will allow you to replace lists without building the index again.

Another option, relevant in case where you have several predefined lists, is to store the serialized index and load it asynchronously with B4XSerializator.
 
Upvote 0
Top