kfealz wrote:
> Thanks for the quick responses!
> 
> I tried:
> 
> ImageView test = (ImageView)findViewById(R.id.contactImg);
> test.setImageResource(R.drawable.ruski);
> 
> Null pointer on R.drawable.ruski.

Meaning setImageResource() complains because of a null pointer? 
R.drawable.ruski should be an integer -- you can confirm this by 
examining the R.java file.

> ruski.png is in res/drawable, so I'm not sure why it can't find it.
> It finds it when I set the source in the layout XML file.

That's mighty strange.

One slim possibility is that R.java is somehow out of sync with the 
reality of your resource tree. I seem to recall you mentioning you're 
using Eclipse, and so I don't know if maybe it's getting too smart for 
its own good or something. On a whim, try renaming R.java to R.java.wtf 
and rebuilding. That should force a fresh R.java and, perhaps, clears up 
this problem.

You might also take a peek at the ImageSwitcher1 API demo:

http://code.google.com/android/samples/ApiDemos/src/com/google/android/samples/view/ImageSwitcher1.html

and see if there's anything that leaps out at you that you're doing 
differently than that demo, which successfully uses setImageResource().

Another thing would be if you could post your full stack trace from the 
exception out of the adb logcat results, as that might provide more clues.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
The Busy Coder's Guide to Android Development -- coming in June 2008!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to