tags:

views:

258

answers:

1

Hi

I have a layout which contains a ListView. Each View (row) in this ListView is a LinearLayout which contains 3 Views - CheckBox, ImageView and a TextView (Horizontal)

My problem is like this - if I use the trackball to highlight a row in the ListView , it works (row's background color is Orange). By clicking on the trackball when a row is highlighted, I switch the current displayed layout to another one (setContentView()). Now, if re-displays the original layout with the ListView (I store its instance for re-displaying it, it is not being re-created!), the highlighted row is NOT highlighted anymore. According to google this is OK, and the highlight will come back as soon as I'll use the trackball.

The real problem is that even if I use the trackball to move up or down in the list now, no other row in the ListView becomes highlighted. Instead, in each row which should be highlighted as a result of the scrolling, the TextView becomes selected and I know that since I set the TextView to be ticking (TruncateAt.MARQUEE).

ONLY if I CLICK the trackball, then the highlight comes back to the row which its TextView is ticking at the moment.

I've tried to solve this problem by setting the TextView as not focusable, not clickable, and disabled. I even tried to set setItemsCanFocus(false) on the ListView - still with no success.

Please help me...

Thank you!

A: 

I have a layout which contains a ListView. Each View (row) in this ListView is a LinearLayout which contains 3 Views - CheckBox, ImageView and a TextView (Horizontal)

Instead, use a CheckedTextView and an ImageView, and use android:choiceMode with your ListView.

Now, if re-displays the original layout with the ListView (I store its instance for re-displaying it, it is not being re-created!), the highlighted row is NOT highlighted anymore.

Don't do that. Use a ViewFlipper, or change the visibility of the ListView and whatever else you're showing, or something, if you feel you need to keep this all in one Activity. Or, as Mr. Lew suggests, when you click on the ListView, go launch another Activity.

I suspect the combination of these will help with your problem.

CommonsWare
About the CheckedTextView, I didn't know about this View, but I don't think this is my problem. As for the choice mode - I didn't mention it, but I do set the choice mode to be MULTIPLE, since I want several items to be chosen.About the ViewFlipper - This is anoter class I was not familiar with, but after reading about it, It is not a good solution for me (I think...) - There is no option to just do a single flip, only start flipping and than stop it... I even tried to find an event for when a view is being flipped but there is no such thing.Thanks.
WhiteTigerK
"but I do set the choice mode to be MULTIPLE, since I want several items to be chosen" -- which means you must use CheckedTextView for it to work properly, period. "There is no option to just do a single flip" -- please read the documentation more closely. Or, take a look at http://github.com/commonsguy/cw-android/tree/master/Fancy/Flipper1/
CommonsWare