Skip to content

Instantly share code, notes, and snippets.

@gavilanch
Last active August 25, 2017 23:40
Show Gist options
  • Save gavilanch/b6c276325410d62ad0b7072f16e79a30 to your computer and use it in GitHub Desktop.
Save gavilanch/b6c276325410d62ad0b7072f16e79a30 to your computer and use it in GitHub Desktop.
// MainActivity
public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater.Inflate(Resource.Menu.newsActionMenu, menu);
return base.OnCreateOptionsMenu(menu);
}
public override bool OnOptionsItemSelected(IMenuItem item)
{
switch (item.ItemId)
{
case Resource.Id.action_read_later:
HandleReadLater();
return true;
default:
return base.OnOptionsItemSelected(item);
}
}
private void HandleReadLater()
{
Toast.MakeText(this, "read later", ToastLength.Short).Show();
}
// En newsActionMenu.xml
<?xml version="1.0" encoding="utf-8" ?>
<!--For all properties see: http://developer.android.com/guide/topics/resources/menu-resource.html-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_read_later"
android:showAsAction="always"
android:icon="@drawable/read_later_white" />
</menu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment