Finally, i change my code and use univeral-image-loader library
I use paperadapter to display url image like the code ,it works fine.
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
Drawable[] imageDrawable = new Drawable[3];
for (int i = 0; i < 3; i++) {
imageDrawable[i] = LoadImageFromWebOperations(server_url+ image_name.replace(" ","")+ "_0" +String.valueOf(i + 1) + ".jpg");
}
imageView = new ImageView(mContext);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setImageDrawable(imageDrawable[position]);
container.addView(imageView, 0);
return imageView;
}
but i want to use asynctask to do this,like the code
@Override
public Object instantiateItem(final ViewGroup container, final int position) {
AsyncTask<String, Void, Drawable[]> loadingImage = new AsyncTask<String, Void, Drawable[]>(){
@Override
protected Drawable[] doInBackground(String... params) {
// TODO Auto-generated method stub
Drawable imageDrawable[] = new Drawable[3];
for (int i = 0; i < 3; i++) {
imageDrawable[i] = LoadImageFromWebOperations(server_url
+ image_name.replace(" ","")+ "_0" + String.valueOf(i + 1) + ".jpg");
System.out.println("doInBackground="+position);
}
return imageDrawable;
}
@Override
protected void onPostExecute(Drawable[] result) {
System.out.println("onPostExecute="+position);
imageView = new ImageView(getBaseContext());
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setImageDrawable(result[position]);
container.addView(imageView, 0);
}
});
}
}; loadingImage.execute();
return imageView;
}
it do not work fine.i found that the position "1" is null without image,but position 0 and 2 is not null,waiting for some suggestion,thanks!