Android Question Questions about SearchView --> Switched to B4XSearchTemplate


Active Member
Licensed User
I've stumbled on the problem with AutoCompleteEditText not being able to search for strings which are not preceded by space, for example TU-874 is never returned if 874 is typed.
So I decided to switch to SearchView, however, new questions have arisen.
When I added it to my project it stays always on top of all the other controls in the activity. I wanted to try to send it to back when it's designed, but then I cannot bring it to front again.
I attach the original example of the SearchView, with a panel added in the activity.
A second question is, how could a _Click event be added so that it would handle when the edittext is clicked?
I would appreciate any help.


    45.5 KB · Views: 49


Licensed User
So I decided to switch to SearchView,
Before I answer your question, let me warn you that when Erel sees you are using an old class 'SearchView' based on a listview, he ain't going to be too thrilled, because he is going to tell you to use the more cross platform and newer B4XSearchTemplate as part of XUI Views (need this XUI Views lib checked). I think we have by now figured out Erel too.
Now to your question:
In the class module of SearchView change the declaration of lv and et from private to public:
Public et As EditText
Public lv As ListView
then in your activity create add this to hide both components:

Then you can have a button to toggle the SearchView between visible or not:
Sub btn_Click
    If btn.Text="Show" Then  ' set the button text to 'Show' initially in designer
    Else if btn.Text="Hide" Then       
    End If
End Sub
Upvote 0