Hadn't thought of using a StateListDrawable, which worked perfectly.
Thanks!

On May 23, 8:15 pm, Zsolt Vasvari <[email protected]> wrote:
> I don't know if this is expected behvior, but this kind of stuff you
> should probably handle with a StateListDrawable.  That way, you don't
> need to mess around with the focus handling, which I found to be quite
> messy (buggy?) in Android.
>
> On May 24, 11:09 am, Tom <[email protected]> wrote:
>
>
>
>
>
>
>
> > I want to have the background of an AutoCompleteTextView change
> > whenever the focus switches to the view. Seems easy enough, but after
> > overriding the onFocusChange method, I've noticed the focus switches
> > every time I call setBackgroundResource. To clarify, this code
>
> >         @Override
> >         public void onFocusChange(View v, boolean hasFocus) {
> >                 if (hasFocus) {
> >                     v.setBackgroundResource(0);
> >                 } else {
>
> > v.setBackgroundResource(R.drawable.search_inactive);
> >                 }
> >             }
> >         }
>
> > results in onFocusChange getting called twice, with hasFocus switching
> > values on each call, such that if the view is not focused, tapping it
> > will result in the calls:
>
> >   onFocusChange(view, true)
> >   onFocusChange(view, false)
>
> > Is this expected behavior?

-- 
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