Android Question Questions about SearchView --> Switched to B4XSearchTemplate

padvou

Active Member
Licensed User
Hello,
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.
Thanks
 

Attachments

  • SearchViewExample.zip
    45.5 KB · Views: 49

Mahares

Expert
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:
B4X:
Public et As EditText
Public lv As ListView
then in your activity create add this to hide both components:
B4X:
SearchView1.lv.Visible=False
 SearchView1.et.Visible=False

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