Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to make drawer items do something when clicked?

Hi there!

I am trying to get my drawer items to produce a toast notification when I click on them. No success, after hours and hours of trying and looking through the internet. Could you please tell me what I am doing wrong?

This is my code:

public override bool OnOptionsItemSelected (IMenuItem item) { switch (item.ItemId) { case Android.Resource.Id.Home: mDrawerLayout.OpenDrawer((int)GravityFlags.Left); return true; case Resource.Id.french: Toast.MakeText(this, "French", ToastLength.Long).Show(); return true; case Resource.Id.german: Toast.MakeText(this, "German", ToastLength.Long).Show(); return true; default: return base.OnOptionsItemSelected(item); } }

And this is my axml:

<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android=""> <group android:checkableBehavior="single"> <item android:id="@+id/french" android:title="French" /> <item android:id="@+id/german" android:title="German" /> </group> </menu>


Best Answer


  • StrangerweatherStrangerweather GBMember ✭✭

    Wonderful. Works perfectly!
    Thank you so much! :smile:

  • alexisvidalalexisvidal USMember

    one question, how to uncheck the other items before pressed?? they stil show checked when press a new one

Sign In or Register to comment.