Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a drop down next to the search input field in Android?

Tags:

android

search

In the system-wide search on my HTC Desire (Froyo), I see a little drop down left to the search input field that allows to select where I want to search (All, web, apps).

How can I implement this in an application of mine? The search tutorial on the Google developer site does not address this.

So in a scenario like the following, taken from the Android docs,

I would like to click on the books and then get some sort of menu to e.g. select "words", "headings" as search mode.

Update: I am not looking for the QuickAction dialog itself, but rather how to attach something to the books icon that reacts on touch, so that I could attach the QuickAction or a new activity or ... And I want to use the standard Android Search Dialog as described in http://developer.android.com/guide/topics/search/search-dialog.html

like image 324
Heiko Rupp Avatar asked Mar 31 '11 15:03

Heiko Rupp


1 Answers

You can't modify the system's search dialog. So if you want customizations like making a drop-down menu appear when the user touches the icon, you'll have to implement your own dialog. This would make your search non-standard so I wouldn't advise it.

However, if I can't talk you out of it, you can see how Android's built-in search dialog is implemented here:

  • https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/SearchDialog.java

In Android 3.x this gets a little easier with the introduction of the SearchView class.

like image 88
Ed Burnette Avatar answered Sep 20 '22 15:09

Ed Burnette