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!
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 trial
I get the error get drawable is deprecated what should I change it to?
Drawable drawable = getResources().getDrawable(page.getImageId()); mImageView.setImageDrawable(drawable);
it says that getDrawable is deprecated, what should I do?
Seth Kroger56,412 Points
Option: Do nothing.
"Deprecated" doesn't mean it won't work, but its use is discouraged moving forward. It won't prevent your app from compiling and building.
With this particular one, you'll have a problem trying to fix it because the fix is only valid for API level 21+ (Lollipop). You'll almost certainly get an error that it's not supported by your project's minimumSdkLevel (14 or 15).
Andrew Winkler37,739 Points
I was able to get mine working using ResourcesCompat. java Drawable drawable = ResourcesCompat.getDrawable(getResources(), page.getImageId(), null); mImageView.setImageDrawable(drawable);
Evan Tidwell7,608 Points
Drawable drawable = getResources().getDrawable(page.getImageId);
Drawable drawable = getDrawable(page.getImageId());