Search with suggestion

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.

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close