Xamarin.Forms. Android. Badge for an item in the action bar?

DenisZakharov.2605DenisZakharov.2605 USMember
edited February 2016 in Xamarin.Forms

Hello.
Is it possible and how to add a badge for an action bar item using Xamarin.Forms?

I used PageRenderer for iOS, here is the code:

public class PageWithBadgeToolbarItemsRenderer : PageRenderer
    {

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var page = this.Element as Page;
            if (page == null)
                return;

            var items = page.ToolbarItems.Select(item => 
                {
                    var badgeItem = item as ToolbarItemWithBadge;
                    return badgeItem == null 
                        ? item.ToUIBarButtonItem() 
                            : new UIBarButtonItemWithBadge(badgeItem, this.NativeView, false);
                });

            this.NavigationController
                .TopViewController
                .NavigationItem
                .SetRightBarButtonItems(items.ToArray(), true);
        }
    }

But I don’t see how to do any customisation of items for android.

The screen example attached.

Thank you for your help.

Answers

Sign In or Register to comment.