我試圖通過從列表視圖提取this 提示從網絡上延遲加載圖像唯一的問題是,當視圖被列表適配器回收時,它會導致列表中第一行加載錯誤的圖像。當我阻止適配器回收視圖時,它工作正常,但它不是執行listview最有效的方法。有沒有一種方法,我們可以在列表視圖中執行延遲加載的圖像,而視圖中的行被回收?如何在使用循環視圖的listview中進行延遲加載?
0
A
回答
0
我們可以避免錯誤的圖像通過在imageview的作爲標籤設置URL獲取加載。每次加載圖片時,我們都需要檢查正在加載圖片的網址。緩存的圖片加載之前負責下載和緩存圖像
//after image is downloaded, before loading it to the view
//cross check if this image-view is recycled if yes,
//getTag returns different URL than the one which is used to download image
String url = (String) m_imageViewRef.get().getTag();
if(url != null && url.compareTo(m_url) == 0){
m_imageViewRef.get().setImageBitmap(result);
使用同一個概念:請
if(referenceImageURL.length()!=0){
//Store the image URL as Tag on the image view
holder.refImageView.setTag(referenceImageURL);
// use the image loader to download and load the image
//pass the image-view and the URL to image loader
imageManager.loadImage(referenceImageURL,holder.refImageView);
}else{
//URL is empty for this list-item
//set null on Tag and load default image here
holder.refImageView.setTag(null);
...
}
的ImageManager視圖 - 用於圖像的圖像:看看下面
活動的解決方案image-view
+0
我想通了,但忘了把它發佈在這裏,這是我最終做的:)謝謝反正 – Nitin 2013-05-21 05:32:44
2
參考以下link..may他們幫助你
Lazy load of images in ListView
http://androidsnips.blogspot.com/2010/08/lazy-loading-of-images-in-list-view-in.html
+0
這是我已經嘗試過的確切的事情,但如果您使用此和回收視圖以及顯示的第一個圖像將不正確。 – Nitin 2012-01-06 08:28:23
相關問題
- 1. 在ListView中延遲加載圖像
- 2. 在地圖視圖中延遲加載?
- 3. 使用db4o進行延遲加載
- 4. Android - 使用onScrollListener在ListView中延遲加載圖像的實現
- 5. 如何在我的「for循環」中進行延遲?
- 6. AngularJS延遲視圖加載
- 7. Hibernate延遲加載視圖
- 8. 在循環中延遲iplescript不延遲
- 9. 使用節點JS中的延遲進行循環播放
- 10. 淘汰賽延遲加載和循環
- 11. 使用SQLite中的數據在UIScrollView中進行延遲加載
- 12. 如何使用Application.OnTime來延遲循環
- 13. HOWTO:Long ListView wirh縮略圖延遲加載?
- 14. 延遲jquery循環延遲
- 15. 如何在C中的DataGridView中進行延遲加載#
- 16. 在循環中使用JQuery Ajax延遲
- 17. 如何用角度使用MongoDB數據進行延遲加載
- 18. 如何延遲while循環?
- 19. 如何給循環添加延遲?
- 20. 使用epoll主循環延遲執行
- 21. 在循環中添加延遲
- 22. UScrollView延遲加載卸載視圖
- 23. 在WordPress中延遲循環
- 24. 如何使用延遲加載模塊進行子路由?
- 25. 如何使用PLINQ進行延遲加載?
- 26. 如何使用BXSlider進行延遲加載
- 27. 如何使用Require.js和angularjs進行延遲加載
- 28. 如何使用依賴注入容器進行延遲加載?
- 29. 在ASP.NET MVC視圖中加載內容使用Ajax延遲
- 30. 在LayoutMode中使用LongListSelector進行延遲加載= Grid
你能否說出你的回收意味着什麼?你每次獲取圖像時都打電話給bitmap.recycle()嗎? – san 2012-01-06 09:10:02
@Santhosh不,他的意思是一個視圖可以被另一個項目使用,通過'getView(...)'中的'convertView'參數' – rds 2012-01-06 10:49:00
嘿接受幫助你解決問題的答案,或者如果你做出了不同的解決方案,就添加解決方案。分享與ppl .. – Shruti 2012-10-19 08:45:10