When a user presses the Search hard key on the device, Android shows the Quick Search Bar. How do I disable the Quick Search Bar?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
In order to completely disabled the Quick Search Bar, override the method onSearchRequested()
and return true unconditionally.
回答2:
override onKeyDown in your activity:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_SEARCH) {
return true;
} else return super.onKeyDown(keyCode, event);
}