Reputation: 9010
I want to create a custom SearchView by having a horizontal LinearLayout containing an EditText and a button. The EditText is where the user enters the search query.
Normally when we are using a SearchView, we
declare a searchable activity by configuring it to receive ACTION_SEARCH
intent in the manifest.
declare our searchable configuration file by using the meta element in the manifest.
enable system-assisted search (in which the system delivers the search query to the searchable activity, provides voice search, displays search suggestions etc.) for the SearchView by configuring it. This is done by passing it a SearchableInfo
object:
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView(); // Assumes current activity is the searchable activity searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
The question is that can I use the custom search widget (the LinearLayout with Edittext and Button) I have described, and still enable system-assisted search (by some way like the one described above) for it?
Upvotes: 1
Views: 613
Reputation: 1070
You can listen to addTextChangedListener of an edit text and on each change check for the query string in your list of item.
Upvotes: 0