ImageView.setImageURI does NOT work when trying to assign a R.drawable.X Uri

Try this

Uri imgUri=Uri.parse("android.resource://my.package.name/"+R.drawable.image);
imageView.setImageURI(null); 
imageView.setImageURI(imgUri);

This is a workaround for refreshing an ImageButton, which tries to cache the previous image Uri. Passing null effectively resets it.

Solution suggested from this book: Sams Teach Yourself Android Application Development in 24 Hours – Highly recommendable to read.

Leave a Comment

tech