How can I highlight a row in a ListView backed by a CursorAdapter knowing the row ID of the item?
+1
A:
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:
- Extend your existing adapter class to create your own custom one
- Override
getViewTypeCount()
to return2
, since you have two types of rows (normal and special) - Override
getItemViewType()
to return0
or1
, depending on whether the position is the one for your desired_id
or not - Override
bindView()
and based on the item view type, inflate and tailor the row as needed
CommonsWare
2010-08-19 21:53:29
I mean make the row stand out from the others in any way possible.
JRL
2010-08-19 21:56:04
@JRL: see above edit
CommonsWare
2010-08-19 22:35:37