示例#1
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.ActionBarMenu, menu);

            var       overflow_item = menu.FindItem(Resource.Id.overflowMenuShare);
            IMenuItem checkItem     = menu.FindItem(Resource.Id.overFlowMenuDarkTheme);

            if (mThemeId != Resource.Style.Black)
            {
                checkItem.SetChecked(checkItem.IsChecked);
            }
            else
            {
                checkItem.SetChecked(!checkItem.IsChecked);
            }

            var actionprov = new Android.Support.V7.Widget.ShareActionProvider(this);

            MenuItemCompat.SetActionProvider(overflow_item, actionprov);
            var test = MenuItemCompat.GetActionProvider(overflow_item);

            shareActionProvider = test.JavaCast <Android.Support.V7.Widget.ShareActionProvider>();

            shareActionProvider.SetShareIntent(CreateShareIntent());

            return(true);
        }
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            this.MenuInflater.Inflate(Resource.Menu.main_menu, menu);

            var shareItem = menu.FindItem(Resource.Id.action_share);
            var test = MenuItemCompat.GetActionProvider (shareItem);
            actionProvider = test.JavaCast<Android.Support.V7.Widget.ShareActionProvider>();

            var intent = new Intent(Intent.ActionSend);
            intent.SetType("text/plain");
            intent.PutExtra(Intent.ExtraText, "ActionBarCompat is Awesome! Support Lib v7 #Xamarin");

            actionProvider.SetShareIntent (intent);

            return base.OnCreateOptionsMenu(menu);
        }
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            //change menu_share1 to your name
            MenuInflater.Inflate (Resource.Menu.menu_details, menu);
            var shareItem = menu.FindItem (Resource.Id.action_share);
            var provider = MenuItemCompat.GetActionProvider (shareItem);
            actionProvider = provider.JavaCast<Android.Support.V7.Widget.ShareActionProvider> ();
            var intent = new Intent (Intent.ActionSend);
            intent.SetType ("text/plain");
            var shareText = string.Format (Resources.GetString (Resource.String.share_text), viewModel.Place.Name);
            if (!string.IsNullOrWhiteSpace (viewModel.Place.Website))
                shareText += " " + viewModel.Place.Website;

            intent.PutExtra (Intent.ExtraText, shareText);
            actionProvider.SetShareIntent (intent);
            return base.OnCreateOptionsMenu (menu);
        }
示例#4
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            this.MenuInflater.Inflate(Resource.Menu.main_menu, menu);

            var shareItem = menu.FindItem(Resource.Id.action_share);
            var test      = MenuItemCompat.GetActionProvider(shareItem);

            actionProvider = test.JavaCast <Android.Support.V7.Widget.ShareActionProvider>();

            var intent = new Intent(Intent.ActionSend);

            intent.SetType("text/plain");
            intent.PutExtra(Intent.ExtraText, "ActionBarCompat is Awesome! Support Lib v7 #Xamarin");

            actionProvider.SetShareIntent(intent);


            return(base.OnCreateOptionsMenu(menu));
        }
示例#5
0
        public override bool OnCreateOptionsMenu(IMenu menu)
        {
            //change menu_share1 to your name
            MenuInflater.Inflate(Resource.Menu.menu_details, menu);
            var shareItem = menu.FindItem(Resource.Id.action_share);
            var provider  = MenuItemCompat.GetActionProvider(shareItem);

            actionProvider = provider.JavaCast <Android.Support.V7.Widget.ShareActionProvider> ();
            var intent = new Intent(Intent.ActionSend);

            intent.SetType("text/plain");
            var shareText = string.Format(Resources.GetString(Resource.String.share_text), viewModel.Place.Name);

            if (!string.IsNullOrWhiteSpace(viewModel.Place.Website))
            {
                shareText += " " + viewModel.Place.Website;
            }

            intent.PutExtra(Intent.ExtraText, shareText);
            actionProvider.SetShareIntent(intent);
            return(base.OnCreateOptionsMenu(menu));
        }