java - Set bind view in simple adapter? -
java - Set bind view in simple adapter? -
i want setup view binder in simple adapter show photos contacts, set 2 text view's name , number hash map, 3rd value image view want set contact photo corresponding contact id. give thanks in advance, wolf.
here code :
arraylist<hashmap<string, string>> mapa = new arraylist<hashmap<string, string>>(); contentresolver cr = getcontentresolver(); cursor cur = cr.query(contactscontract.contacts.content_uri, null, null, null, null); if(cur.getcount() > 0){ while(cur.movetonext()){ id = cur.getstring(cur.getcolumnindex(contactscontract.contacts._id)); string photouri = cur.getstring(cur.getcolumnindex(contactscontract.contacts.photo_id)); if(integer.parseint(cur.getstring(cur.getcolumnindex(contactscontract.contacts.has_phone_number))) > 0){ final cursor numcur = cr.query(contactscontract.commondatakinds.phone.content_uri, null, contactscontract.commondatakinds.phone.contact_id + " = ?", new string[]{id}, null); for(numcur.movetofirst(); !numcur.isafterlast(); numcur.movetonext()){ brtel = numcur.getstring(numcur.getcolumnindex(contactscontract.commondatakinds.phone.number)); ime = cur.getstring(cur.getcolumnindex(contactscontract.contacts.display_name)); tmpime = new string[] {ime}; for(int = 0; < tmpime.length; i++){ hashmap<string, string> imemapa = new hashmap<string, string>(); imemapa.put("imelista", ime); imemapa.put("checkbox", photouri); imemapa.put("mobilni", brtel); mapa.add(imemapa); } } numcur.close(); } } // while } simpleadapter sa = new simpleadapter(getapplicationcontext(), mapa, r.layout.imenik, new string[] {"imelista", "checkbox", "mobilni"}, new int[] {r.id.tvimeimenik, r.id.cboznaci, r.id.tvsamoproba}); sa.setviewbinder(simpleslika); limenik.setadapter(sa);
and view binder :
private final simpleadapter.viewbinder simpleslika = new simpleadapter.viewbinder() { public boolean setviewvalue(view view, object data, string textrepresentation) { if (view instanceof imageview && info instanceof bitmap) { imageview v = (imageview)view; v.setimagebitmap((bitmap)data); // homecoming true signal bind successful homecoming true; } homecoming false; } };
but it's not working. help please???
yes possible, create own adapter (extends baseadapter), override getview method , there add together bitmap imageview.
public contactadapter(activity a,arraylist<object> list) { activity = a; inflater = (layoutinflater)activity.getsystemservice(context.layout_inflater_service); } @override public view getview(final int position, view convertview, viewgroup parent) { view v=convertview; if(convertview==null) v = inflater.inflate(r.layout.contact, null); imageview image = (imageview)v.findviewbyid(r.id.img); }
something this. have extends this. check : android - how do lazy load of images in listview
java android
Comments
Post a Comment