On Sat, Sep 1, 2012 at 7:42 AM, LiTTle <[email protected]> wrote:
> It is me again!!! When I select the first item and then I did everything Mr.
> Mark Murphy said when I scroll down and then come back to the top, the first
> item is black again instead of pink? Is there any way to store this option
> (for example selected=true) and repaint the same object as pink the next
> time I come across with this item?

In getView(), if you are going to manage colors yourself, you need to
*always* set the *right color*. *You* know what the right color is;
Android does not.

That being said, I question the entire approach that you are taking.

If your ListView is being shown in conjunction with other widgets
(e.g., managed by a fragment), where the content of those other
widgets is determined by what the user tapped on in the ListView, then
the notion of maintaining a highlight is appropriate. This UI pattern
-- what Google refers to as the "master-detail pattern", is
particularly useful on landscape large-screen devices. On Android
3.0+, Android has an "activated" style that you can use to manage the
color for you. On older devices (e.g., you want master-detail on a
Kindle Fire), then you might need to manage this more yourself, using
the techniques that you are trying.

In any other circumstance, I counsel you against doing what you are
doing. For example, it may interfere with those using your app with a
D-pad, trackball, arrow keys, or some other pointing device, as they
need to distinguish which row is selected by the pointing device, so
they know which row will be "clicked" when they, say, press down on
the trackball or on the center D-pad button.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to Android Development_ Version 4.1 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to