Reputation: 1986
I am making a small application where I have to call search dialog on search button click please give 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
Upvotes: 0
Views: 2972
Reputation: 8079
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
Upvotes: 0
Reputation: 6353
Override search button as :
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_SEARCH){
//do, what you want
}
}
Upvotes: 2