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,369
Last edited:

SamuelP

Member
Licensed User
There are two parts in code, that seems make no effect, if I comment them out.

1) in manifest-Editor
B4X:
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)

2) in Main
B4X:
Private Sub IME_HeightChanged (NewHeight As Int, OldHeight As Int)
    SearchView1.ActivityHeightChanged(NewHeight)
End Sub

For what are they? Do I need them?
 

Ricky D

Well-Known Member
Licensed User
Longtime User
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.

View attachment 53072

Tutorial about handling large, searchable lists: https://www.b4x.com/android/forum/t...e-list-with-searchview-b4xserializator.61872/
Where can I see the properties and methods?
 

Ricky D

Well-Known Member
Licensed User
Longtime User
I'd like to ask does autocompleteedittext or this one do auto complete as I type? I mean does it fill the text portion with the first match of the list and then refine the list as I type more text
 
Last edited:

Erind Jushaj

Member
Licensed User
Erel, would it be possible to attach the same list to multiple Editboxes?

I have dynamical added editboxes that would work with the same list, CoinBox1, Coinbox2, etc.

Is this possible?
 

Erind Jushaj

Member
Licensed User
The problem I had Erel is that because I am adding dynamically I cannot call the xxx_TextChanged as my editboxes have all the time a different name...
 

aidymp

Well-Known Member
Licensed User
Longtime User
At the risk of getting in trouble for raising an old thread (again) ;)

This is a very basic problem but i'm confused several times the question has been asked & answered! but always the same answer and no example (i am very visual and need to see it!!!)

B4X:
Sub Class_Globals
Private et As EditText
'change it to public!!

so

B4X:
Sub Class_Globals
Public et As EditText
'change it to public!!

should make et. available in my main module??

I need it as i want to clear the edit text when i have done with it. I could do it in the class. but it would be easier in Main..

Thanks


Aidy
 

Inman

Well-Known Member
Licensed User
Longtime User
Is it possible to add SearchView to activity via code?

Also in the thread about B4XSerializator, it is mentioned that SearchView has a limit of 500 list items. Is that still the case? I can't use B4XSerializator as the server is not in my control.
 
Status
Not open for further replies.
Top