我想使用AsyncTask将图像加载到我的FlipView中,但我不知道如何继续。 我需要使用AsyncTask,因为应用程序强制关闭,因为我有20个图像要从drawables加载。在AsyncTask中填充ViewFlipper
private class asyncImage extends AsyncTask<Void, Void, Void>{
int i;
@Override
protected Void doInBackground(Void... params) {
for (i=0;i<imageID.length;i++){
image = new ImageView(getBaseContext());
image.setId(i);
image.setImageResource(imageID[i]);
image.setBackgroundDrawable(getResources().getDrawable(R.drawable.border));
image.setScaleType(ImageView.ScaleType.FIT_XY);
FlipV.addView(image);
}
return null;
}
protected void onPostExecute(Void result){
image.setBackgroundDrawable(getResources().getDrawable(R.drawable.border));
image.setScaleType(ImageView.ScaleType.FIT_XY);
for(int x=0;x<imageID.length;x++){
FlipV.addView(???); //How to add images into FlipView?
}
}
}
我卡在将图像添加到FlipView。任何帮助?
如果您从资源中加载图片,则不需要使用asyntstask – silentnuke 2012-07-27 11:32:45
,但如果我的图片超过10张,应用程序崩溃。一种记忆问题。 – 2012-07-27 11:58:13
什么在logcat?或者你得到ANR错误? – silentnuke 2012-07-30 19:25:12