Search with suggestion

Updated 15 December 2016


Searching in android is a very important feature and mostly present in every application nowadays. There are two ways to provide the search one is search widget and the other is or a search dailog.

We can also show the suggestions to user in the search view. The suggestions can be the recent search items or the custom suggestions you added in your application.

Here we will implement a search dialog with the recently searched terms as sugessions. Firstly we have to implement a searchable configuration. Here is your searchable.xml

Place this xml at res/xml folder of your application.

Now make a search activity that will be called internally when a search is performed. The activity should be single top. Lets call it SearchActivity

To make the system know which one of your activity is search activity. So define your search activity within th manifest as

Now to store your recent searches for suggestion make a authority provider as we have already defined in Searchable.xml i.e MySuggestionProvider

You can also use DATYABASE_MODE_2LINES, it is helpful in showing a descriptive text below your suggestion text. The search is matched with both the suggestion text as well as descriptive text.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home