所以問題是 1.我們正在使用listView的聊天應用程序 2。每次發送聊天或rec時,我們都會更新arrayList並更新適配器,並執行notifydatasetAdaper()以刷新列表視圖。 3.因此,如果我們在聊天中發送10個圖像,然後發送第11個聊天信息(比如說文字chtat),然後調用notifydatasetadapter(),則在這種情況下,所有10個圖像都會刷新。 4.所以我需要停止刷新圖像。 5. ListView必須刷新,而不刷新圖像對話listview停止刷新圖像視圖
所以任何想法我怎麼能實現這個..或者可能在錯誤的路徑m請告訴我正確的做法..... !!!
我也嘗試過使用picaso,但庫與okhttp庫衝突.... !!!
而且我這是在展示這些圖像
public class ImageFromSd extends AsyncTask<Object, Bitmap, Bitmap> {
ImageView im;
// int targetWidth = 200;
// int targetHeight = 200;
@Override
protected Bitmap doInBackground(Object... params) {
// TODO Auto-generated method stub
Bitmap bitmap = null;
try {
im = (ImageView) params[0];
String path = (String) im.getTag();
Log.d("ankit", "image path :::::" + path);
bitmap = BitmapFactory.decodeFile(path);
// bitmap.compress(CompressFormat.JPEG, 100, new
// FileOutputStream(
// path));
//
// bitmap = Bitmap.createScaledBitmap(bitmap, targetWidth,
// targetHeight, false);
}
// catch (FileNotFoundException e) {
// e.printStackTrace();
// bitmap = null;
// }
catch (OutOfMemoryError e) {
e.printStackTrace();
bitmap = null;
} catch (NullPointerException e) {
e.printStackTrace();
bitmap = null;
} catch (Exception e) {
e.printStackTrace();
bitmap = null;
}
return bitmap;
}
@Override
protected void onPostExecute(Bitmap result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (result != null) {
im.setScaleType(ScaleType.FIT_CENTER);
im.setImageBitmap(result);
}
}
}
and then calling it like this
im.setTag(items.get(i).getTextChat());
new ImageFromSd().execute(im);
請張貼代碼列表視圖和適配器 – AndroidEnthusiast 2014-09-26 14:30:17