I am working on an app where the list item are complex, TextView and two ImageButtons. I have looked at the around for a solution, and tried all that I have seen, still nothing.
you can create View.OnClickListner object which can listen your imagebutton click in getView. onListItemClick generally used to handle row click event not items in rows.
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflator = (LayoutInflater) getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View listItem = inflator.inflate(R.layout.medcince_list_item, null);
ImageButton mEdit = (ImageButton)listItem.findViewById(R.id.item_edit);
mEdit.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
// HERE YOU CAN HANDLE BUTTON CLICK. POSITION YOU CAN HAVE FROM getView already.
}
});
mEdit.setTag(getItem(position));
ImageButton mHistory = (ImageButton)listItem.findViewById(R.id.item_history);
mHistory.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
// HERE YOU CAN HANDLE BUTTON CLICK. POSITION YOU CAN HAVE FROM getView already.
}
});
mHistory.setTag(getItem(position));
return listItem;
}