android - How to efficiently click items with a listview -



android - How to efficiently click items with a listview -

i have list view , in each list item have image views , 3 text view, 3 of these image view deed image button i.e respond on click events , 2 of text view. have tried using itemonclicklisteneri mean this

@override public void onitemclick(adapterview<?> arg0, view convertview, int pos, long arg3) { // todo auto-generated method stub bomb = (imageview) convertview.findviewbyid(r.id.bomb); log.i("item clicked", "item clicked @ pos" + position); bomb.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub // perform action on click //run ever task neccessary } }); }

but has problem responds on sec click. know has parent , kid focus haven't been able around that.

i tried using the

static class view holder except got implementation wrong not respond @ after 2 clicks.

also using custom adapter, used straight getview overide method found out hard way isn't best ways implement want do.

please need work me cause tried coupleof thing other above mentioned have failed.

get view codes

@override public view getview(int position, view convertview, viewgroup parent) { // todo auto-generated method stub pos = position; if(convertview == null) { convertview = inflater.inflate(r.layout.singlepost, parent, false); holder = new viewholder(); holder.bomb = (imageview) convertview.findviewbyid(r.id.bomb); holder.bomb.setonclicklistener(bomb_listener); convertview.settag(holder); } else { holder = (viewholder)convertview.gettag(); holder.bomb.setonclicklistener(bomb_listener); } homecoming convertview; } private onclicklistener bomb_listener = new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub log.i("homeadapter", "boomb clicked @ positon" + pos); holder.bomb.setimageresource(r.drawable.redheart); } }; static class viewholder { textview reporter; textview shell; textview sheller; textview likesnum; textview favsnum; textview comnum; imageview bomb; imageview star; imageview comment; }

with new getview implementation still don't exact item intend click

add clicklistener code block within getview() i.e create view,

getview(...) { if (view == null) { viewholder = new viewholder(); view = ...inflateview code... view bomb = view.findviewbyid(r.id.bomb); bomb.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub // perform action on click //run ever task neccessary } }); view.settag(viewholder); } else { viewholder = (viewholder)view.gettag(); } }

android listview onitemclicklistener

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -