public class Adapter extends BaseAdapter {
private static ArrayList<ItemDetails> aList;
private LayoutInflater l_Inflater;
public Adapter(Context context, ArrayList<ItemDetails> results) {
aList = results;
l_Inflater = LayoutInflater.from(context);
}
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = l_Inflater.inflate(R.layout.mylist1, null);
holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.name);
holder.title = (TextView) convertView.findViewById(R.id.txt1);
holder.ago = (TextView) convertView.findViewById(R.id.date);
holder.member = (TextView) convertView.findViewById(R.id.member);
holder.itemImage = (ImageView) convertView.findViewById(R.id.img_t);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.name.setText(aList.get(position).getName());
holder.title.setText(aList.get(position).getTitle());
holder.ago.setText(aList.get(position).getAgo());
holder.member.setText(aList.get(position).getMember());
String url = aList.get(position).getImg();
Log.d("image_name", url);
if (url.length() > 9) {
Log.d("image_url", url);
DownloadFileFromURL img = new DownloadFileFromURL(holder.itemImage, position);
img.execute(url);
if(img.pos == position) {
holder.itemImage.setImageBitmap(img.bitmap);
}
aList.get(position).setChanged();
}
notifyDataSetChanged();
return convertView;
}
public static class ViewHolder {
TextView name;
TextView title;
TextView ago;
TextView member;
ImageView itemImage;
}
}
asynck任務類成功後我改變形象滾動時我的列表視圖項圖像改變
protected void onPostExecute(String file_url) {
if (imageViewReference != null) {
ImageView imageView = imageViewReference.get();
imageView.setImageBitmap(bitmap);
}
}
}
請正確格式化代碼 – Ramesh