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 a Weather App (2015) Hooking Up the Model to the View Setting the Weather Icon

getresources deprecated

The line should now be as such:

    Drawable drawable = ContextCompat.getDrawable(this, mCurrentWeather.getIconId());
    mIconImageView.setImageDrawable(drawable);

mods can you add this to the teachers notes? source https://developer.android.com/reference/android/support/v4/content/ContextCompat.html http://stackoverflow.com/questions/29041027/android-getresources-getdrawable-deprecated-api-22

1 Answer

Here is the solution:

Drawable drawable = ResourcesCompat.getDrawable(getResources(), mCurrentWeather.getIconID(), null);
mIconImageView.setImageDrawable(drawable);
Paritosh Sahni
Paritosh Sahni
Courses Plus Student 4,853 Points

Hello Benjamin,

Thank you for the solution. Just out of curiosity, can you please tell me the way (maybe the process) you find these solutions? I mean, do you just type the correct questions on web and get the desired answers or finding it on your own by hit and trial method in Android Studio?

Regards, Paritosh.