thanks Joseph...  i have no idea why the selector background does not
JUST WORK...

I ended up having to 'force' the right backround in the onItemSelected
callback and in the getView of the adpater when the position ==
selected position of the gallery.

If anyone else knows why this is not working I would love to fix it so
I did not have to write custom code to handle what the platform should
be handling by default.

thanks, Mark

On Jul 24, 2:51 pm, Joseph Earl <joseph.w.e...@gmail.com> wrote:
> Not setting anything interesting that I'm aware of.
>
> My getView in my adapter looks like:
>
> public View getView(int position, View convertView, ViewGroup parent)
> {
>         ImageView i;
>
>         if (convertView == null) {
>                 i = (ImageView) View.inflate(mContext, R.layout.gallery_item,
> null);
>         }
>         else {
>                 i = (ImageView) convertView;
>         }
>         i.setImageDrawable(R.drawable.image);
>         // some other stuff
>
>        return i;
>
> }
>
> And in the gallery_item layout XML file there is just an ImageView
> with the selector in my earlier post as the background.
>
> On Jul 24, 6:59 pm, Mark Nuetzmann <mark.nuetzm...@gmail.com> wrote:
>
>
>
> > I changed my selector to be exactly what you have (but using my
> > drawables ;) and it still behaves the same way; no selected state.
> > How are you setting the items that are being returned by the adapter?
> > Are you setting anything interesting on those views that might result
> > in it working for you?
>
> > On Jul 24, 12:45 pm, Joseph Earl <joseph.w.e...@gmail.com> wrote:
>
> > > 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