I have used context.getDrawable()
like this in my project:
Drawable greenProgressbar = context.getDrawable(R.drawable.custom_progressbargreen);
But Eclipse is giving me an error that it needs a Minimum API level of 21
. This would mean after a quick google search my APP will only be usable on Android 5.0
. Since not all devices are using this version of android I would like to have an alternative for context.getDrawable()
.
I had a same situation which I wanted to reference getDrawable() method which is now deprecated.
what I used,
Hope this will help you
I had a similar problem before. Have you tried to do it like this?
Try adding a
getResources()
after the context, so this:should work.
The previously accepted method has been deprecated, according to the SDK 22 documentation:
As pointed out in this answer better solution would be to use ContextCompat:
ContextCompat.getDrawable(context, R.drawable.***)
Try this: