Created
May 2, 2012 16:11
-
-
Save jheerman/2577854 to your computer and use it in GitHub Desktop.
Action Mode Callback example to create a contextual menu for an Action Bar in M4A
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class MessageAction: Java.Lang.Object, ActionMode.ICallback | |
{ | |
string _title; | |
string _subTitle; | |
public event EventHandler<EventArgs> DeleteActionHandler; | |
public event EventHandler<EventArgs> ViewActionHandler; | |
public event EventHandler<EventArgs> DestroyActionHandler; | |
public MessageAction (string title, string subTitle) | |
{ | |
_title = title; | |
_subTitle = subTitle; | |
} | |
bool ActionMode.ICallback.OnActionItemClicked (ActionMode mode, IMenuItem item) | |
{ | |
switch (item.ItemId) | |
{ | |
case Resource.Id.deleteMessage: | |
if (DeleteActionHandler != null) | |
DeleteActionHandler (null, null); | |
return true; | |
case Resource.Id.viewMessage: | |
if (ViewActionHandler != null) | |
ViewActionHandler(null, null); | |
return true; | |
default: | |
return false; | |
} | |
} | |
bool ActionMode.ICallback.OnCreateActionMode (ActionMode mode, IMenu menu) | |
{ | |
mode.Title = _title; | |
mode.Subtitle = _subTitle; | |
mode.MenuInflater.Inflate (Resource.Menu.message_action_bar, menu); | |
return true; | |
} | |
void ActionMode.ICallback.OnDestroyActionMode (ActionMode mode) | |
{ | |
if (DestroyActionHandler != null) | |
DestroyActionHandler(null, null); | |
} | |
bool ActionMode.ICallback.OnPrepareActionMode (ActionMode mode, IMenu menu) | |
{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment