I have an activity that extends ListActivity, now I want to enable the click listener button in each row of the list. I did read some similar questions like this, but most of that extend from BaseAdapter to get the button. Actually, with the code below the button event was fired, however I have to double click on the row to fire the event.
@Override
// How can I trigger a single button instead of firing whole the row
protected void onListItemClick(ListView l, View v,final int position, long id) {
super.onListItemClick(l, v, position, id);
//removeTask(position);
ImageView remove = (ImageView)v.findViewById(R.id.remove_task);
remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
removeTask(position);
}
});
}
I hope my question makes sense. Thanks