stackman
stackman

Reputation: 342

Xamarin cant add icon to toolbar

I am trying to add a help icon to my app's toolbar however it isnt working and i have no idea why. This is the error I am getting:

09-10 23:09:48.421 D/InputMethodManager( 4907): HSI from window - flag : 0 
Pid 
: 4907
[0:] Could not load image named: {0}: help.png
09-10 23:09:48.695 W/ResourceType( 4907): No package identifier when getting 
value for resource number 0x00000000
09-10 23:09:48.696 E/BitmapFactory( 4907): Unable to decode stream: 
java.io.FileNotFoundException: help.png (No such file or directory)

This how I am adding to the toolbar:

ToolbarItems.Add(new ToolbarItem()
        {
            Icon = "help.png",
            Order = ToolbarItemOrder.Primary,
            Priority = 0,
            Command = new Command(() => Navigation.PushAsync(new HelpPage()))
        });

I have placed the help.png icon on the Resources/drawable folder however it still isnt showing up on the app (the navigation works though, if i tap the space where the icon should be)

Upvotes: 0

Views: 560

Answers (1)

Eru
Eru

Reputation: 397

First of all try setting up the BuildAction of that image to be AndroidResource. If this does not solve the issue, then also you can try:

... = ImageSource.FromFile("help.png");

Cheers! :)

Upvotes: 1

Related Questions