我知道用setImageDrawable(),可是這個drawable=?
drawable對象,有多種,比如這裡用BitmapDrawable
1、從資源中獲取Drawble
private BitmapDrawable getDrawableFromId(int id){ //這個id就是類似R.drawable.lander_firing
Resources res = getResources();
return (BitmapDrawable)res.getDrawable(id);
}
2、從資源中獲取Bitmap圖像
private Bitmap getBitmapFromId(int id){
Resources res = getResources();
BitmapDrawable bitDraw = new BitmapDrawable(res.openRawResource(R.drawable.lander_firing));
Bitmap bm = bitDraw.getBitmap();
return bm;
//mImageView.setImageBitmap(bm);
}