Android: access drawables outside an activity?

You need a reference to the Resources object. Easiest way would be to pass a reference to it in the constructor for your component.

Thanks for your reply. I also thought about what you suggest but my image loader is a singleton. Besides, I would like to keep the image loader as generic as possible.

I tought of using Drawable. CreateFromPath(String path) but can't figure out the correct path... – Rob Jun 1 '10 at 11:40 @Rob: drawables that are in res/drawable are compiled into your apk and are thus not accessible as files. If you want them to be, you'll have to create files on the phone for them, which you'll then be able to access using a path.

– JRL Jun 1 '10 at 11:45 Thanks for the clarification. – Rob Jun 1 '10 at 11:47 @Rob: as an ugly hack, you can set a static Resource reference from within the onCreate method of your launcher activity. – JRL Jun 1 '10 at 11:47.

You can call it via your package. For an image, the syntax would be: .R.drawable.

Not quite as simple as that Zarah. Just use PackageManager: getDrawable (String packageName, int resid, ApplicationInfo appInfo).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions