我知道用setImageDrawable(),可是这个drawable=?
5条回答 默认 最新
danielinbiti 2015-05-22 03:04关注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); }本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 1无用