0

I've followed this tutorial and ctrl-v'd the recommended methods into my code. Setting the imageview looks like this:

        iv.setImageBitmap(
            decodeSampledBitmapFromResource(getResources(), R.id.myPic, 200, 200));

And yet the image doesn't display. The screen goes black, LogCat indicates that memory has been allocated, but nothing appears.

Kolban
  • 13,794
  • 3
  • 38
  • 60
ygu
  • 47
  • 5
  • Where have you placed the `ImageView`? Have you tried copying the code directly, without modifications, and seeing whether that works? – Mapsy Nov 02 '14 at 03:44
  • It's right in the middle of a RelativeLayout. It's just a RelativeLayout with an ImageView centered in the middle of it. And all I did was ctrl-v the code but with private instead of public static. – ygu Nov 02 '14 at 03:45
  • Could you try testing the third method proposed in the solution to this question: http://stackoverflow.com/questions/11182714/bitmapfactory-example Just to confirm you can at least display the image. Then we could focus on whether `decodeSampledBitmapFactory` is doing what's expected. How large is your image? – Mapsy Nov 02 '14 at 03:51
  • Generally, if you have a method which can operate independently of a class, you should keep it static. It may be useful for other areas of your application later on to utilise the functionality you're developing here. – Mapsy Nov 02 '14 at 03:53
  • I made a mistake, I used Thread.sleep() rather than SystemClock.sleep(). Sorry about this. – ygu Nov 02 '14 at 05:12

0 Answers0