Solace
Solace

Reputation: 9010

Is it possible to configure an EditText (instead of SearchView) for Android search (i.e. the system-assisted search)?

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

  1. declare a searchable activity by configuring it to receive ACTION_SEARCH intent in the manifest.

  2. declare our searchable configuration file by using the meta element in the manifest.

  3. 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

Answers (1)

Umang
Umang

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

Related Questions