I use something like:

<selector xmlns:android="http://schemas.android.com/apk/res/android";>
    <item android:state_selected="true" android:drawable="@drawable/
frame_gallery_thumb_selected" />
    <item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/frame_gallery_thumb_pressed" />
    <item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/frame_gallery_thumb_pressed" />
    <item android:drawable="@drawable/frame_gallery_thumb" />
</selector>

as a background for views in my gallery which seems to work perfectly.
I should note that when the selected item is pressed it maintains the
selected state drawable (it was how I wanted it) but you could show
the default press state when the selected item is pressed.

On Jul 24, 6:23 pm, Joseph Earl <joseph.w.e...@gmail.com> wrote:
> Try moving your state_selected statement above your state_pressed item
> and see if it works.
>
> On Jul 24, 6:07 pm, Mark Nuetzmann <mark.nuetzm...@gmail.com> wrote:
>
> > I have a gallery that displays TextViews where the background of each
> > view is the following:
>
> > <?xml version="1.0" encoding="utf-8"?>
> > <selector xmlns:android="http://schemas.android.com/apk/res/android";>
> >     <item
> >         android:state_pressed="true"
> >         android:drawable="@drawable/item_pressed" />
> >     <item
> >         android:state_selected="true"
> >         android:drawable="@drawable/item_selected" />
> >     <item
> >         android:drawable="@drawable/item_idle" />
> > </selector>
>
> > This selector work just fine for the state_pressed and default (idle)
> > states, but the selected item state is never displayed.  I REALLY do
> > not want to force the background of the selected item by changing the
> > background of the view when the onItemSelected event is called.  What
> > is the correct state or correct way to get the TextView background to
> > be set properly.  Is the selected (center) view in the gallery not
> > really selected?  Is there some other state I should put in the
> > selector drawable xml?
>
> > Thanks, Mark.

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

Reply via email to