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 trial

Android Build an Interactive Story App (Retired) Finishing the User Interface Loading the First Page

kris Moore
kris Moore
1,752 Points

depreciated methods.

Android Studio says: ".getDrawable(page.getImageId())" and .getDrawable() also has a strike through it, will this affect the code?

1 Answer

Seth Kroger
Seth Kroger
56,414 Points

"Deprecated" doesn't mean "removed (yet)" so it can still be used. If you want to future-proof your code you change it to:

ContextCompat.getDrawable(getActivity(), R.drawable.name)

What is meant by

R.drawable.name

Do you mean that we should type

Drawable mdDrawable = ContextCompat.getDrawable(page.getImageId(), R.drawable.name);
mImageView.setImageDrawable(mdDrawable); 

Please help.

Seth Kroger
Seth Kroger
56,414 Points

It's the resource id for the Drawable image, which is usually in the form of R.drawable.etc but can be an int variable or result from a method. In the Interactive Story app it should be the image id of the page, i.e., page.getImageId().