Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialsnehal ahire
Courses Plus Student 42 PointsgetDrawable
in my version of android studio ,getDrawable(int) is deprecated. which method can i use in place of this?
1 Answer
Mikkel Madsen
4,229 PointsHi.
The getDrawable is not really deprcated and this is only from api 22. It has just changed a little. Instead of getDrawable(int, id) you will now have to use getDrawable(int, theme). For further reference you can look in the android developer resources. here is documentation for the old getDrawable: https://developer.android.com/reference/android/content/res/Resources.html
here is documentation for new getDrawable api 22 and above: https://developer.android.com/reference/android/content/res/Resources.html#getDrawable(int, android.content.res.Resources.Theme)
here is a little bit from stackoverflow if you need a little reference: http://stackoverflow.com/questions/29041027/android-getresources-getdrawable-deprecated-api-22
and here is two links to descusions on the treehouse forums about: https://teamtreehouse.com/community/deprecated-getresourcesgetdrawablein-id https://teamtreehouse.com/community/getdrawableint-id-is-deprecated-in-api-22
I hope this will help you. :)