With new android API 22 getResources().getDrawable()
is now deprecated.
Now the best approach is to use only getDrawable()
.
What changed? <
Replace this line :
getResources().getDrawable(R.drawable.your_drawable)
with ResourcesCompat.getDrawable(getResources(), R.drawable.your_drawable, null)
EDIT
ResourcesCompat
is also deprecated now. But you can use this:
ContextCompat.getDrawable(this, R.drawable.your_drawable)
(Here this
is the context)
for more details follow this link: ContextCompat