Issue
I'm implementing a MapView with a search feature, and have to perform some specific actions for the search to work well (I.E. turn on the layer of icons the search will query). I'm currently using the OnSearchRequested method to perform these actions. However, if the user cancels out of the search dialog, I want to return the map to its former state (that is, the state prior to pressing the search key).
I read in the documentation where it's possible to do this using an OnCancelListener, however I'm unsure how to add this to the search feature. I understand that with a simple dialog you're creating you can just say dialog.setOnCanelListenr(myListener). However, since the search view is not being controlled by my mapView, how would I set this? Is it even possible?
Solution
Apparently you should Using the Android Search Dialog explains this in detail and links to OnDismissListener instead of OnCancelListener because the latter is only invoked for specific events.setOnCancelListener and friends.
Note - you only need a Context object to retrieve the SearchManager via getSystemService and call setOnCancelListener:
SearchManager searches =
(SearchManager) context.getSystemService(Context.SEARCH_SERVICE);
searches.setOn{Cancel,Dismiss}Listener( ... );
Answered By - Matthew Willis
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.