I'm trying to set the bitmap image of an image view to a bitmap that is returned by another class, below is code snippet:-
imageView = (ImageView) findViewById(R.id.imageView);
Bitmap myBitmap = myModel.loadBitmap(getResources(), R.drawable.nether);
imageView.setImageBitmap(myBitmap);
Here's the model class:-
public class Model {
Bitmap cache;
public Bitmap loadBitmap(final Resources resource, final int i){
new Thread(new Runnable(){
public void run(){
cache = BitmapFactory.decodeResource(resource, i);
}
}).start();
return cache;
}
}
The problem is that the image doesn't display. It displays if the code used to load the bitmap is used before setting the image view bitmap in the same class but the returned bitmap doesn't work.
Any help would be great, thanks!