java - How to update image in listview for android -
i want change image in imageview in listview not working.
bellow data , list adapter.
public class archivedata { public string mto = ""; public imageview mimage; public int mid = 0; public string mtext = ""; public string mdate; } public class archivelistadapter extends baseadapter{ private layoutinflater minflater; private vector<archivedata> marchivevector; public archivelistadapter(context context, final vector<archivedata> data) { marchivevector = data; minflater = layoutinflater.from(context); } public int getcount() { return marchivevector.size(); } public object getitem(int position) { return marchivevector.elementat(position); } public long getitemid(int position) { return position; } public view getview(int position, view convertview, viewgroup parent) { viewholder holder; if (convertview == null) { convertview = minflater.inflate(r.layout.archive, null); holder = new viewholder(); holder.mtxtarchivedate = (textview) convertview.findviewbyid(r.id.date); holder.mtxtarchivetext = (textview) convertview.findviewbyid(r.id.txtarchivetext); holder.mimage = (imageview) convertview.findviewbyid(r.id.list_image); holder.mtxtarchiveto = (textview) convertview.findviewbyid(r.id.toname); convertview.settag(holder); } else { holder = (viewholder) convertview.gettag(); } archivedata data = marchivevector.elementat(position); holder.mtxtarchivedate.settext(data.mdate); holder.mtxtarchivetext.settext(data.mtext); holder.mimage.setimageresource(r.drawable.anonymous_logo); holder.mtxtarchiveto.settext(data.mto); return convertview; } private class viewholder { textview mtxtarchiveto; imageview mimage; textview mtxtarchivetext; textview mtxtarchivedate; }
}
here code in activity updating image:
private archives marchive; private archivelistadapter marchivelistadapter; (int = 0; < marchive.marchive.size(); ++i) { bitmap im = getfacebookphoto(marchive.marchive.elementat(i).mto); marchive.marchive.elementat(i).mimage.setimagebitmap(im); } marchivelistadapter = new archivelistadapter(getactivity(),marchive.marchive); marchivelistadapter.notifydatasetchanged(); mscrollview.setadapter(marchivelistadapter);
it returning error on following row:
marchive.marchive.elementat(i).mimage.setimagebitmap(im);
can me please ?
thank you
i think order wrong:
init:
marchivelistadapter = new archivelistadapter(getactivity(),marchive.marchive); mscrollview.setadapter(marchivelistadapter);
update:
for (int = 0; < marchive.marchive.size(); ++i) { bitmap im = getfacebookphoto(marchive.marchive.elementat(i).mto); marchive.marchive.elementat(i).mimage.setimagebitmap(im); } if(marchivelistadapter!=null){ marchivelistadapter.notifydatasetchanged(); } else { //fallback marchivelistadapter = new archivelistadapter(getactivity(),marchive.marchive); mscrollview.setadapter(marchivelistadapter); }
might have given suggestions.
Comments
Post a Comment