How can I highlight a row in a ListView backed by a CursorAdapter knowing the row ID of the item?
If by "highlight" you mean "select", you will need to manually iterate over your Cursor
, find which position corresponds to that _id
value, then call setSelection()
on the ListView
to select the row with that position. This will only have an impact if the user is not in touch mode, as there is no concept of a selection in a ListView
if the user is using the touch screen.
EDIT
Given your first comment, you will need to do several things:
getViewTypeCount()
to return 2
, since you have two types of rows (normal and special)getItemViewType()
to return 0
or 1
, depending on whether the position is the one for your desired _id
or notbindView()
and based on the item view type, inflate and tailor the row as needed