How can I call search dialog on button click in android?
I am making a small application where I have to call search dialog on search button click please g开发者_如何学运维ive me simple code or simple tutorial because I have seen many example but I am not so expert to call the search dialog please help me thanks in advance
Override search button as :
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_SEARCH){
//do, what you want
}
}
UPDATE: (since we're talking about the hardware button)
Declare a searchable configuration: http://developer.android.com/guide/topics/search/searchable-config.html. There is an example at the bottom of the linked page.
Then create a searchable activity: http://developer.android.com/guide/topics/search/search-dialog.html#SearchableActivity
And then, for any activity that should react to the search button being pressed, do this: http://developer.android.com/guide/topics/search/search-dialog.html#SearchDialog
精彩评论