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 trialUnsubscribed User
5,729 Pointsmethod deprecated
When i am creating a new drawable object and getting resources as image I am getting a deprecated method name getDrawable()
<p> Drawable drawable = getResources().getDrawable(page.getImageId()); </P>
2 Answers
Valerie Makumire
3,262 PointsFor non-themed drawables use this instead:
ResourcesCompat.getDrawable(getResources(), page.getImageId(), null);
Trainer Workout
22,341 PointsTry this
Drawable mDrawable = ContextCompat.getDrawable(this, mPage.getImageId());
jeremiahjacquet
16,885 Pointsthe instructions do not say call the member variable when setting mImageView.setImageDrawable(drawable));
very close though. This works for me Drawable drawable = ContextCompat.getDrawable(this, page.getImageID());
cheng zheng
Courses Plus Student 1,288 Pointscheng zheng
Courses Plus Student 1,288 Pointsnot working, not sure why.