我在Custom Adapter类中使用异步调用来在Listview中加载图像。但是,直到我轻轻向上/向下滚动图像才会显示。请让我知道可能是什么原因。谢谢你的帮助。
private class LoadImage extends AsyncTask<Void, Void, Void>
{
private String fileName = null;
private ImageView imgViewToLoad = null;
LoadImage(String fileName, ImageView imgViewToLoad)
{
this.fileName = fileName;
this.imgViewToLoad = imgViewToLoad;
}
@Override
protected Void doInBackground(Void... args)
{
return null;
}
//This is executed on main UI thread
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
Utils.mImageFetcher.loadImage(fileName, imgViewToLoad);
}
}
This is in my getView()
----------------------
ViewHolderIncomingImg holderInImg = null;
if (null != convertView &&
(convertView.getTag() instanceof ViewHolderIncomingImg && !isFirstMsg))
{
holderInImg = (ViewHolderIncomingImg) convertView.getTag();
if (!multiSelectionMode)
{
if (!mSelectedItemsIds.get(position) && convertView.isActivated())
convertView.setActivated(false);
}
}
else
{
convertView = mInflater.inflate(R.layout.conv_list_item_incoming_img, parent, false);
holderInImg = new ViewHolderIncomingImg();
..............
new LoadImage(convRowItems.get(position).getMessage(), holderInImg.image).execute();
答案 0 :(得分:0)
由于Listview使用回收其视图的概念。异步调用完成后,图像不会显示。
所以去listview延迟加载方法它会帮助你。