FinHead
FinHead

Reputation: 517

Android (Lollipop) EditText onFocus fired multiple times

I have a couple of EditTexts with onFocusChangeListeners

// When the field gains or loses focus
txtMinimumValue.setOnFocusChangeListener(new View.OnFocusChangeListener() {
    @Override
    public void onFocusChange(View view, boolean hasFocus) {
        editFocusChange(view, hasFocus);
    }
});

I'm not having any issues on pre-Lollipop devices, but any Nexus 5's and the onFocusChange is fired about 7 times.

I found this SO: Custom ListAdapter consisting of EditText lose focus called twice

and then I found this Android Open Source Issue that looks related: https://code.google.com/p/android/issues/detail?id=80180 A Project Member said, "The framework version does this too. Fixed for a future release." Anyway to know when appcompat-v7:21.0.3 is released and I can test if this fixes my issue?

Anyone having this same issue?

Upvotes: 4

Views: 2181

Answers (1)

FinHead
FinHead

Reputation: 517

I have numerous filter screens where I might have several views on top and edit boxes, and then a list of values in a ListView. I've been dynamically building the bottom list view of values from arrays, and then programmatically building the top section of views and adding this top section as a header view. This is so the entire screen scrolls together, b/c you shouldn't add a ListView to a ScrollView.

Any EditText views on the top section might have onFocusChange methods to adjust the filter values manually entered. On Lollipop, there must be a bug where these programmatically built views added as a ListView header don't work, b/c the onFocusChange methods were firing repeatedly. I had to build the top as an xml for the onFocusChange methods to fire correctly.

Upvotes: 1

Related Questions