java - Want to do something to view in item that got clicked in list view -
i have 2 buttons in each item set invisible. want, when user clicks on item, buttons in item turn visible.
im using custom adapter list view...
public class locationadapter extends baseadapter{ string [] n; context context; string[] a; int bint = view.invisible; private static layoutinflater inflater=null; public locationadapter(mainactivity mainactivity, string[] names, string[] addresses, int bint) { // todo auto-generated constructor stub this.bint = bint; n=names; context=mainactivity; a=addresses; inflater = ( layoutinflater )context.getsystemservice(context.layout_inflater_service); } @override public int getcount() { // todo auto-generated method stub return n.length; } @override public object getitem(int position) { // todo auto-generated method stub return position; } @override public long getitemid(int position) { // todo auto-generated method stub return position; } public class holder { textview name; textview address; button b1; button b2; } @override public view getview(final int position, view convertview, viewgroup parent) { // todo auto-generated method stub holder holder=new holder(); view rowview; rowview = inflater.inflate(r.layout.rowlayout2, null); holder.name =(textview) rowview.findviewbyid(r.id.edittextname); holder.address =(textview) rowview.findviewbyid(r.id.edittextaddress); holder.b1 = (button) rowview.findviewbyid(r.id.edit); holder.b2 = (button) rowview.findviewbyid(r.id.delete); holder.b1.setvisibility(bint); holder.b2.setvisibility(bint); holder.name.settext(n[position]); holder.address.settext(a[position]); rowview.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub toast.maketext(context, "you clicked "+n[position], toast.length_long).show(); } }); return rowview; } }
can please give me ideas on how need this?
you need set onitemclicklistener
on listview
, change visibility of buttons
inside onitemclick()
.
also note current implementation of locationadapter
not check if(convertview == null)
, not set viewholer
tag of row view
.
Comments
Post a Comment