我目前的工作有哪些使用LazyLoader方法,所以我ahve以下類填充的列表中的應用:LazyLoader imageLoader空指針異常?
FileCache.java, ImageLoader.java, LazyAdapter.java, Utils.java
基本上圖像加載fin當我填充列表,但是我想然後顯示選定的單個項目視圖上的選定列表項的圖像時,它被選中。所以,當用戶點擊一個列表項時,他們將被帶到一個新的活動,以查看該項目周圍的所有細節。爲了節省數據庫調用我收集了所有需要的數據在列表中把它藏在現場,然後我用下面的方法將它傳遞給單個項目視圖:
String ImageURL = ((TextView) view.findViewById(R.id.ImageURL)).getText().toString();
Intent i = new Intent(getApplicationContext(), VenueItem.class);
i.putExtra("ImageURL", ImageURL);
startActivity(i);
這則將該URL傳遞和一堆我發送到新Activity的其他數據。當它使用下面的方法達到了新的活動我讀數據:
String image_url;
Intent i = getIntent();
image_url = i.getStringExtra("ImageURL");
ImageView thumb_image=(ImageView) findViewById(R.id.itemImage); // thumb image
imageLoader.DisplayImage(image_url, thumb_image); //This is the line it fails on
正如你可以看到我已經強調了上面它似乎失敗行,我得到一個NullPointerException錯誤,即使我已經調試代碼,當它擊中那條線時,它傳遞的2個參數都存在。對於圖像加載器的代碼如下:
final int stub_id = R.drawable.noimage;
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);
}
}
我認爲這是事做,我也許調用圖像加載器的方式,有人可以幫我這個,因爲它是那麼討厭?或者有人可以告訴我一個更好的方式來獲取已經緩存並顯示在列表中的圖像,以顯示單項活動?
感謝
安置自己的logcat跟蹤 – Pragnani 2013-03-17 19:33:27
調試應用程序,並檢查它們具有空值。 – 2013-03-17 19:35:17