我有调整图像大小的方法,我想从数组中获取参数,但它一直显示错误说
incompatible types
found int
required android.graphics.drawable.Drawable
这是我的方法
public Drawable ResizeImage (int imgResize){
Display imgPost = getWindowManager().getDefaultDisplay();
double dvcWidth = imgPost.getWidth();
BitmapDrawable imgBD = (BitmapDrawable)this.getResources().getDrawable(imgResize);
double imgHeight = imgBD.getBitmap().getHeight();
double imgWidth = imgBD.getBitmap().getWidth();
double imgRatio = dvcWidth/imgWidth;
int newImgHeight = (int) (imgHeight*imgRatio);
Bitmap imgBmap = BitmapFactory.decodeResource(getResources(),imgResize);
Drawable imgDrawable = new BitmapDrawable(this.getResources(),getResizedBitmap(imgBmap,newImgHeight,(int) dvcWidth));
return imgDrawable;
}
我的数组
int[] imgDvc= new int[]{
ResizeImage(R.drawable.pc),
R.drawable.ps4,
R.drawable.xbone
}
我通过这里调用我的数组
List<HashMap<String,String>> aList = new ArrayList<HashMap<String,String>>();
for(int i=0;i<10;i++){
HashMap<String, String> hm = new HashMap<String,String>();
hm.put("Dvc", Integer.toString(imgDvc[i]) );
aList.add(hm);
}
String[] game= {"Dvc"};
我用它来填写列表视图,谢谢你的答案。
答案 0 :(得分:0)
如果您只想放置3张图片,只需使用3张图片视图,然后按比例调整尺寸