[android-developers] Re: Focus changes when changing the background for AutoCompleteTextView
Hadn't thought of using a StateListDrawable, which worked perfectly.
Thanks!
On May 23, 8:15 pm, Zsolt Vasvari <zvasv...@gmail.com> 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 <thomas.j.benn...@gmail.com> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home