These days the Android Searchview is used to trigger an event when it is closed.
First looked at the next, found that there is a setoncloselistener, overjoyed, think it is it, the results point to a half-day no response, and then the morning search, summed up the following several cases:
1 inside the source, implement Setoncloselistener in the Close () method, there is an empty input box, Might conflict with Searchview's Setonquerytextlistener interface Onquerytextsubmit (String query)
2 Setoncloselistener only works at 3.2, and ICS doesn't seem to work.
And the native Seachview is (Searchview) Menuitem.getactionview ();
Then you can start from the MenuItem, see if there is any incident response, a look, of course there are
Finally looked up the information, sure enough, is as follows:
if (currentversion >= build.version_codes. Ice_cream_sandwich) { Menuitem.setonactionexpandlistener (New menuitem.onactionexpandlistener () { @Override public boolean Onmenuitemactionexpand (Menuitem item) { return true; } @Override public boolean onmenuitemactioncollapsE (Menuitem item) { //TODO Add Close Event return true; } }); } else { msearchview.setoncloselistener (new searchview.oncloselistener () { @Override public boolean onclose () { //todo Add Close Event return false; } }); }
Shutdown events for Android Searchview