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 trialMartin Batista
4,606 PointsI need to find alternative for deprecated getDrawable() method...
the compiler doesn't like the following code: Drawable drawable = getResources().getDrawable(int id, Resources.android.content.res.Resources.Theme theme);
What's an alternative method I can use?
compiler output: StoryActivity.java:67: error: '.class' expected Drawable drawable = getResources().getDrawable(int id, Resources.android.content.res.Resources.Theme theme); ^
thanks in advance, Martin
2 Answers
Kourosh Raeen
23,733 PointsHi Martin - You can find the answer in this thread: https://teamtreehouse.com/community/getdrawableint-id-is-deprecated-in-api-22
Martin Batista
4,606 PointsThank you, likewise!
Martin Batista
4,606 PointsMartin Batista
4,606 PointsThank you Kourosh,
With your help, I got to this solution:
Drawable drawable = null; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { drawable = getResources().getDrawable(page.getImageId(),null); }
Kourosh Raeen
23,733 PointsKourosh Raeen
23,733 PointsGlad you got it to work! Happy coding!