Exemplo n.º 1
0
 public void SetBadge(Page page, ToolbarItem item, string value, Color backgroundColor, Color textColor)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         var toolbar = CrossCurrentActivity.Current.Activity.FindViewById(Resource.Id.toolbar) as Android.Support.V7.Widget.Toolbar;
         if (toolbar != null)
         {
             if (!string.IsNullOrEmpty(value))
             {
                 var idx = page.ToolbarItems.IndexOf(item);
                 if (toolbar.Menu.Size() > idx)
                 {
                     var menuItem = toolbar.Menu.GetItem(idx);
                     BadgeDrawable.SetBadgeText(CrossCurrentActivity.Current.Activity, menuItem, value, backgroundColor.ToAndroid(), textColor.ToAndroid());
                 }
             }
         }
     });
 }
 public void SetBadge(Page page, ToolbarItem item, string value, Color backgroundColor, Color textColor)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         var Current = CrossCurrentActivity.Current.Activity;
         if (Current != null)
         {
             var toolbar = MyShellToolbarAppearanceTracker.mytoolbar;
             if (toolbar != null)
             {
                 if (!string.IsNullOrEmpty(value))
                 {
                     var idx = page.ToolbarItems.IndexOf(item);
                     if (toolbar.Menu.Size() > idx)
                     {
                         var menuItem = toolbar.Menu.GetItem(idx);
                         BadgeDrawable.SetBadgeText(CrossCurrentActivity.Current.Activity, menuItem, value, backgroundColor.ToAndroid(), textColor.ToAndroid());
                     }
                 }
             }
         }
     });
 }