B4A Library [Class] SearchView - More powerful alternative to AutoCompleteEditText

Status
Not open for further replies.
Edit: better to use B4XDialog + B4XSearchTemplate

SearchView is made of an EditText and ListView. When the user enters text into the EditText the ListView shows the items that start with this text or that contain the text (in this order).

This view is useful for allowing the user to select an item from many items.

Advantages over AutoCompleteEditText:
  • SearchView uses an internal index that is built when you call SetItems. This allows it to quickly find the matches.
  • SearchView also shows items that contain the input text (not just prefixes).
  • The class code can be further customized as needed.

upload_2017-2-21_17-48-19.png


Tutorial about handling large, searchable lists: https://www.b4x.com/android/forum/t...e-list-with-searchview-b4xserializator.61872/
 

Attachments

  • SearchView.zip
    45.1 KB · Views: 2,378
Last edited:

shashkiranr

Active Member
Licensed User
Longtime User
Hi Erel,

im using this search view with Ultimate List View. The problem i am facing is when i set the index for the list, the ULV is not loading properly since the time taken to set the index is more. i tried to create a service and do the indexing in the background not able to pass the output back to the calling Class Module.

Kindly let me know how i can use the Indexing of the searchview in a service.

Regards,
SK
 

anallie0

Active Member
Licensed User
Longtime User
hi Erel
I'm using your example but I have a problem.
If I insert it in a black panel, there are no display problems.
But if I insert it in a white panel, the imputbox is not visible.
how can I make it black ?
 

Mahares

Expert
Licensed User
Longtime User
In the below sub in the class module add the items I listed. You can change the colors to your liking:
B4X:
Public Sub Initialize (Callback As Object, EventName As String)
    et.Initialize("et")

    et.Color=Colors.White 'add this
    et.TextColor=Colors.black   'add this
    et.TextSize=24  'add this
 
Last edited:

katrad

Member
Licensed User
Longtime User
I love this searchview, my only want is that when someone searches something that the list still stays there. I'm using the searchview to show places on a map and would like to retain that result, I have also implemented the "show all" function, so I dont know what to change to make that happen.

Thank you very much in advance!!!
 

katrad

Member
Licensed User
Longtime User
I love this searchview, my only want is that when someone searches something that the list still stays there. I'm using the searchview to show places on a map and would like to retain that result, I have also implemented the "show all" function, so I dont know what to change to make that happen.

Thank you very much in advance!!!

No, what I mean is when a user searches and there is more defined detail in the list that even after they select something (from that list) that it isnt redrawn and the original (search) list is intact. So, they can select others from that (prev searched) list.
 

katrad

Member
Licensed User
Longtime User
No, what I mean is when a user searches and there is more defined detail in the list that even after they select something (from that list) that it isnt redrawn and the original (search) list is intact. So, they can select others from that (prev searched) list.
PS. I didnt know you could do that, cool! (about F7)
 

katrad

Member
Licensed User
Longtime User
PS. I didnt know you could do that, cool! (about F7)
Let me try to make this simple, if I could retrive the original search (text), I think I could make it just go to that. I just cant find how to get the original search text out of the the search view. I always get what I'm searching for (selected) not the texted searched. It's because its in the other class. (I think)
 
Last edited:
Status
Not open for further replies.
Top