Issue
I'm trying to get an Android.Graphics.Drawables.Icon
but unsure of how to do so.
I've got this code:
Icon icon = Resources.GetDrawable(Resource.Drawable.tab_subs);
I'm not able to do this, because of exception:
Cannot implicitly convert type Android.Graphics.Drawables.Drawable
to Android.Graphics.Drawables.Icon
I've tried casting into an Icon
, no dice:
Android.Graphics.Drawables.Icon icon = (Icon)Resources.GetDrawable(Resource.Drawable.tab_subs);
To make matters worse, Resources.GetDrawable(int)
is obsolete: 'deprecated'
...and resource tab_subs
is available in other contexts. For some reason, the resource is not available in the context of MainActivity
https://github.com/hexag0d/BitChute_Mobile_Android_BottomNav/blob/AppSettingsAdder/MainActivity.cs
Does anyone know how to get an Icon
in xamarin.android ?
Here is the Resource
file:
Solution
Maybe this is what you're after?
Icon icon = Icon.CreateWithResource(this, Resource.Drawable.tab_subs);
More information and other ways to load an Icon are documented here... https://developer.android.com/reference/android/graphics/drawable/Icon#public-methods_1
Answered By - Robert Bruce
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.