java - Targeting strings in a listview android -
listview.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> parent, view view, int position, long id) { if(position == 1 ){ toast.maketext(getapplicationcontext(), "click listitem number " + position, toast.length_long) .show(); }else{ }
i have list view custom adapter works fine , when click item gets correct position. how can exract field views text out of position. ie
holder.txtdesc = (textview) convertview.findviewbyid(r.id.desc);
i want target desc field out of position listem clicked.. know can use hash mapping there way target field view on item click list position? know "webby" sure java has same flexibility
public view getview(int position, view convertview, viewgroup parent) { viewholder holder = null; rowitem rowitem = getitem(position); layoutinflater minflater = (layoutinflater) context .getsystemservice(activity.layout_inflater_service); if (convertview == null) { convertview = minflater.inflate(r.layout.list_item, null); holder = new viewholder(); holder.txtdesc = (textview) convertview.findviewbyid(r.id.desc); holder.txttitle = (textview) convertview.findviewbyid(r.id.title); convertview.settag(holder); } else holder = (viewholder) convertview.gettag(); holder.txtdesc.settext(rowitem.getdesc()); holder.txttitle.settext(rowitem.gettitle()); return convertview; }
how can exract field views text out of position. ie
holder.txtdesc = (textview) convertview.findviewbyid(r.id.desc);
inside onitemclick()
can use:
textview textview = (textview) view.findviewbyid(r.id.desc); // use textview.gettext().tostring() description
since convertview
adapter same object view
in listener.
Comments
Post a Comment