Create Simple Menu in Android Using Visual Studio

To create simple menu or navigation on android is easy. You must add few code something like this.
Add this code to mymenu.xml.
mymenu.xml code:

<?xml version="1.0" encoding="utf-8" ?> 
<menu xmlns:android="">
  <item android:id="@+id/home"
  <item android:id="@+id/kategori"
  <item android:id="@+id/setting"

And then put this into your mainactivity.cs
Mainactivity.cs code:

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace Simple_Menu
   [Activity(Label = "Simple_Menu", MainLauncher = true, Icon = "@drawable/icon")]

   //Bagian utama
   public class MainActivity : Activity
      //Buat menu
      public override bool OnCreateOptionsMenu(IMenu menu)
         MenuInflater.Inflate(Resource.Menu.mymenu, menu);
         return base.OnCreateOptionsMenu(menu);
      //Menu Kita di Klik
      public override bool OnOptionsItemSelected(IMenuItem item)
         switch (item.ItemId)
            case Resource.Id.home:
               Button Homeact = FindViewById<Button>(Resource.Id.MyButton);
               Homeact.Click += delegate { Homeact.Text = string.Format("{0} clicks!", count++); };
               //Kode aksi or Action code
               return true;
            case Resource.Id.kategori:
               //Kode aksi or Action code
               return true;
            case Resource.Id.setting:
               //Kode aksi or Action code
               return true;

         return base.OnOptionsItemSelected(item);

      int count = 1;
      protected override void OnCreate(Bundle bundle)

         // Set our view from the "main" layout resource

         // Get our button from the layout resource,
         // and attach an event to it
         Button button = FindViewById<Button>(Resource.Id.MyButton);

         button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };

For complete tutorial you can download project or see the video below. Download Project:

Download Project
Lihat Video:

Leave a Reply

Your email address will not be published. Required fields are marked *