android start user defined activity on search button pressed @ handset

后端 未结 2 1966
遇见更好的自我
遇见更好的自我 2020-12-09 15:48

I am using following code to start activity when user pressing search button on the handset

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
          


        
相关标签:
2条回答
  • 2020-12-09 16:32
     @Override
     public boolean onSearchRequested() {
    
         // your logic here
    
         return false;  // don't go ahead and show the search box
     }
    
    0 讨论(0)
  • 2020-12-09 16:40

    The Search button and system's search request are both working the same when invoked from any activity of your app. If you want to override it you will have to override it for EVERY activity you want it to work from in the same way. Unfortunately, there is no way to override it "globally", neither a way to subclass/style/theme the default search popup. So sad, google.

    0 讨论(0)
提交回复
热议问题