actually I\'ve read some previous questions about this...
this is the code that I use
auto = (ListView)findViewById(R.id.auto);
String[] projection =
An easier solution to this probably is when your Activity implements OnClickListener and you set the (casted) Context as OnClickListener to any view you want in the Adapter. For more robust code you can check with instanceof.
public class MyActivity implements OnClickListener {
// ...
}
public class MyAdapter extends CursorAdapter {
@Override
public void bindView(View view, Context context, Cursor cursor) {
final TextView tv = (View) view.findViewById(R.id.text1);
setOnClickListener((OnClickListener)context);
tv.setTag(cursor.getPosition());
}
}
For convenience you can set the items position in the adapter as Tag of the view. That way you can easily lookup the whole item in the adapter.