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

Rifqi Fahmi
Rifqi Fahmi
23,164 Points

learning to use and handle many image resources in android !

I wonder is there a lesson to teach student how to handle bitmap on android especially large bitmap. Why i ask this ? because I follow this lesson https://teamtreehouse.com/library/build-a-simple-android-app-2014 and I want to have some images that represent each fact. It still work fine for 3-4 facts, but when I try to compile more than 4 facts and run the app it give an exception "OutOfMemory Exception" because the app try to load all the image at once.

It would be nice if teamtreehouse add some lesson for this kind of topic. So that we can make such as our own gallery app hehe :) Ben Jakuben Ben Deitch

Thanks :D

1 Answer

Ben Deitch
STAFF
Ben Deitch
Treehouse Teacher

Try putting the images in the /res/drawable-nodpi directory (you may need to create it). It's not well documented, but I think I've used it in the past as a quick fix for this issue.

Ben Deitch
Ben Deitch
Treehouse Teacher

I think that way's a lot more work ;).

If a drawable is in the nodpi folder, then Android will scale it to fit the device which MAY cause the image to become a little blurry/pixelated. But on the other hand, dealing with 5 different drawable folders and OutOfMemory Exceptions is a TON of extra work. So it's really up to you. Are you trying to have the best image quality possible, or would you rather do a lot less work with nodpi?

Rifqi Fahmi
Rifqi Fahmi
23,164 Points

haha i am just curious with this bitmap things, i think handling the bitmap resource is important so we can get nice user experience. nodpi also work, But nodpi is kind of simple and it still load the image at once, imagine if i have tons of fact and user have to wait for the system to load at a time, it will took their precious time hehe.

Thanks for answering :D