android - Get the listItem ID in a onClick method of SetOnClickListener method of an adapter? -
i have activity lists objects array objects through custom adapter. row of adapter contains several edittext's , layout clickable , deleting of object selected. intention object can updated clicking on item (which shows activity) , deleting clicking on layout. that, have implement updating , deleting differents setonitemclicklistener's.
i have done updating setting setonitemclicklistener listview of objects , sending whole object new activity through putextra , getintent.
the problem deleting. have implemented onclicklistener directly on adapter, this:
holder.layouteliminar.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { //here call async task delete object but, t id object??? }
that code goes fine when click on layout of row don't know way obtain id of object selected in listview. know how??
do not hesitate ask me more code or details. please excuse english, not native.
you can set tag view on getview
:
holder.layouteliminar.settag(theidofyourobject);
note view.settag(object tag)
takes object
parameter (documentation). assume want set id of object delete string
tag.
and then, on onclick
holder.layouteliminar.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { linearlayout layouteliminar; // retrieve layouteliminar v // ... // id of object delete tag string id = (string) layouteliminar.gettag(); } };
Comments
Post a Comment