ImageViews의 배열에서 Parse.com의 이미지를 가져 오려고합니다. 그러나 ImageLoader 클래스에서 nullpointerException으로 응용 프로그램이 충돌합니다. parse.com과 ImageViews에 5 개의 이미지가 있습니다. 하나의 ImageView는 드로어 블 폴더에 이미지 세트가 있습니다. 따라서 Imageviews 1-6의 배열에서 5 개의 이미지가 파싱되어 동적으로로드됩니다. HomeActivity은 다음과 같습니다에서 onCreate()에서ImageLoader에서 예외가 발생하여 Parse.com에서 이미지를 가져옵니다.
ImageView ad1,ad2,ad3,ad4,ad5,ad6;
List<ParseObject> ob;
private ImageView[] imgs = new ImageView[5];
int k=0;
public ImageLoader imgl;
:
imgl=new ImageLoader(getApplicationContext());
ad1=(ImageView) findViewById(R.id.ad1);
ad2=(ImageView) findViewById(R.id.ad2);
ad3=(ImageView) findViewById(R.id.ad3);
ad4=(ImageView) findViewById(R.id.ad4);
ad5=(ImageView) findViewById(R.id.ad5);
ad6=(ImageView) findViewById(R.id.ad6);
imgs[0] = ad2;
imgs[1] = ad3;
imgs[2] = ad4;
imgs[3] = ad5;
imgs[4] = ad6;
try {
// Locate the class table named "Footer" in Parse.com
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Adverts");
query.orderByDescending("updatedAt");
query.whereEqualTo("Status", true);
ob = query.find();
for (ParseObject country : ob) {
ParseFile image = (ParseFile) country.get("imageFile");
imgl.DisplayImage(image.getUrl(), imgs[k]);
k=k+1;
System.out.println("the urls are"+image.getUrl());
}
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
하여 ImageLoader 클래스에서 : 나는 imageView.setImageResource(stub_id);
에서 nullpointer을 얻고있다
public ImageLoader(Context context) {
fileCache = new FileCache(context);
executorService = Executors.newFixedThreadPool(5);
}
final int stub_id = R.drawable.ic_launcher;
public void DisplayImage(String url, ImageView imageView) {
imageViews.put(imageView, url);
Bitmap bitmap = memoryCache.get(url);
if (bitmap != null)
imageView.setImageBitmap(bitmap);
else {
queuePhoto(url, imageView);
imageView.setImageResource(stub_id);
}
}
도와주세요.