You could use a custom-made OnItemClickListener
that implements OnClickListener
.
private class CustomAdapter extends BaseAdapter implements OnClickListener {
public MyAdapter() {
/* Your constructor */
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.custom_row, null);
}
// take the CheckBox and set the listener.
CheckBox cbx = (CheckBox) convertView.findViewById(R.id.checkbox);
cbx.setOnClickListener(this);
// set the listener for the whole row.
convertView.setOnClickListener(new OnItemClickListener(position));
return convertView;
}
@Override
public void onClick(View v) {
Log.v(TAG, "Row button clicked");
}
}
private class OnItemClickListener implements OnClickListener{
private int mPosition;
OnItemClickListener(int position){
mPosition = position;
}
@Override
public void onClick(View v) {
Log.v(TAG, "onItemClick at position" + mPosition);
}
}
}
Also note that putting a focusable view in a list item prevents the firing of onListItemClick() when the list item is clicked.
Hope this helps.