views:

70

answers:

1

I'm looking for suggestions on how to go about adding a ListView selector that is 'permanent'. By this, I mean a single row in the ListView is always highlighted; it should move up or down in reponse to any D-pad presses (i.e. like the default selector) but also remain set/highlighted if the user were to scroll the ListView in either direction (i.e. it's still highlighted even when it's off-screen).

I've looked at using the standard selector mechanism, but am unable to get the selector to remain in place if the ListView is touched (and thus scrolled), so it makes me think that this isn't the best option? Perhaps there's a <selector> "state_*" that I've ignored?

The other option would be to use the onItemSelected() callback, but at first look this appears more convoluted?

Any suggestions/recommendations/experiences gratefully receieved.

Cheers

James

A: 

I'm looking for suggestions on how to go about adding a ListView selector that is 'permanent'.

Please do not do this. There is no selection in touch mode, and that is by design. As suggested in this article, "Use the appropriate feature if you need persistent selection (radio button, check box, the ListView choice mode, etc.). Do not try to keep the focus or selection in touch mode."

CommonsWare
Thanks Mark.The reasoning behind the 'permanent selection' is because I have two Views, and each making a selection in the first View needs to be 'mirrored' in the ListView. Currently, I use setSelectionFromTop() to bring the item to the top of the list. That's fine, but having an additional visual clue (i.e. colour) would help the user identify what has just happened in the ListView (particularly as the last item in the ListView obviously cannot be set to the top of the ListView).So, the way to do this would be to leave the 'selection' and just set the background?
James
@James: "making a selection in the first View needs to be 'mirrored' in the ListView." -- why? "So, the way to do this would be to leave the 'selection' and just set the background?" -- messing with backgrounds is somewhat painful and will conflict with true selection. If you really need this, perhaps toggle some icon between `View.VISIBLE` and `View.INVISIBLE` to indicate the row that is being manipulated in the `View`, or change some text color. But, honestly, I can't quite fathom a UI where providing two places to select the same thing (`View` and `ListView`) is a good use of screen space.
CommonsWare
Yes. That's what I feared about changing the background. I'll go with the (icon/text colour) indication. Thanks again.
James