B4i Library [class] SearchView

This class is similar to B4A SearchView class. It allows the user to filter a list of items based on a term (prefix matches first followed by other matches).

It uses the new RichString class to highlight the matching terms. Note that the scrolling and filtering performance in release mode are very good. It can be a bit jumpy in debug mode.

New version of SearchView is now available. It is implemented as a custom view. It also properly handles the keyboard state.


  • SearchView.zip
    7.5 KB · Views: 291
Last edited:


Active Member
Licensed User
Is it possible to add an item with more than just one line? I believe with the equivalent in B4A you can add singleline and doubleline. Is it possible to add a custom view or something (i.e., an entry with a line and an icon?)


Well-Known Member
Licensed User
How do I put default text on it
there is no sv.text = "something"

and second question, how do I do sv2.enabled = false
since I want to enable it only after sv1.text has something in it
(sv1 = cities, sv2 = streets)
I wish to load only the relevant streets by city
Last edited:

narek adonts

Well-Known Member
Licensed User
I have updated Erel's SearchView with using the iOS native SearchViewController (like in iMessage, Whatsapp, Viber,...)

It is just the basic wrapping so you can contribute to it.

For current users of SearchView you do not need modify anything in your code.

Project attached.



  • searchView.zip
    4.2 KB · Views: 154

John Woodsmall

Active Member
Licensed User
This works very well on most text files. However I have 271 "Div/state" files...the entire list of cities
in the world. The 3 one I tested is "UK.TXT" which is a simple ascii list of the cities in the UK.
I get "encode-error" when I try to open it:"Error reading file. Incorrect encoding"

I have checked the file and can not find any weird letters?


  • uk.txt
    47.1 KB · Views: 11

John Woodsmall

Active Member
Licensed User
In the "New" from:"narek-adonts" search view above (which I have added to my app) it does not seem to return a value to
the sv_ItemClick(Value As String)
On the first one (above) it works correctly. But on the new one which looks great(i would love to use it)
it does not seem to return a value. All i did was replace the new *.bas to my app.


Staff member
Licensed User
Open the file with Notepad++ and change its encoding to UTF8:


However this file is too large for SearchView to index. It will probably be quite slow.
You should follow these steps: https://www.b4x.com/android/forum/threads/61872/#content