I have a% custom% co within a snippet, which takes the data from ListView
. In each row of CursorAdapter
there are several ListView
, one TextView
(a check box) and a button.
What I want is to attend to the clicks of each view independently: The ImageView
(when clicking will be reversed its marked / unmarked position), the button and the ImageView
( another fragment will open to edit the fields).
For the button, there's no problem: I put a TextViews
in setOnClickListener
and you're done.
It is assumed that the rest could handle them from the fragment with:
mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
long viewId = v.getId();
...
}
But CursorAdapter
only returns the viewId
that I use for RelativeLayout
.
I've seen this article , where it easily resolves: Put this in the ListView
of the adapter:
viewHolder.button1 = (Button) convertView.findViewById(R.id.button1);
viewHolder.button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
((ListView) parent).performItemClick(v, position, 0);
}
});
But I do not have a getView
, since I'm using a getView
, and in CursorAdapter
I do not know how to get a reference to bindView
to use Listview
.