android - Get url from NetworkImageView -
i have listview populated 1 of items in each row networkimageview. i´m passing each row intent putextra() detail_product activity.
with textviews i've being doing:
string pname = ((textview) view.findviewbyid(r.id.name)).gettext().tostring(); ... i.putextra(tag_name, pname);
how proceed networkimageview? can't use gettext
or getresources()
.
edit
@override public view getview(int position, view convertview, viewgroup parent) { if (inflater == null) inflater = (layoutinflater) activity .getsystemservice(context.layout_inflater_service); if (convertview == null) convertview = inflater.inflate(r.layout.list_row, null); if (imageloader == null) imageloader = appcontroller.getinstance().getimageloader(); networkimageview thumbnail = (networkimageview) convertview .findviewbyid(r.id.thumbnail); textview name = (textview) convertview.findviewbyid(r.id.name); product m = productitems.get(position); // thumbnail image string url = m.getthumbnailurl(); thumbnail.setimageurl(url, imageloader); thumbnail.settag(url); // name name.settext(m.getname()); }
no getter available networkimageview provides url set it.
one way use tags networkimageview. set image url tag networkimageview.for eg. holder.thumbnail.settag(imgurl) inside getview(...) of adapter listview.
in onitemclick listener listview
listview.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { networkimageview v = (networkimageview) view.findviewbyid(r.id.thumbnail); string imgurl = (string) v.gettag();
another way through reflection [please avoid, see referred "murl", private variable used inside networkimageview , change @ point of time]
class nw = networkimageview.class; try { field url=nw.getdeclaredfield("murl"); url.setaccessible(true); string imgurl=(string) url.get(your_networkview_object); } catch (nosuchfieldexception | illegalaccessexception | illegalargumentexception e) { e.printstacktrace(); }
Comments
Post a Comment