New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SwitchButton used in a custom SwitchPreference #69
Comments
In complement to the original post, I just want to add that one of the workaround I have tested was to set a Hope this help! |
Hi there,
I am using the SwitchButton in a subclass of SwitchPreference, and then this preference instance is added with other standard ones (EditTextPreference, Preference,...) in a PreferenceFragment.
My SwitchButton is implemented using a widget layout like this :
The customization of preferences can be a little bit tricky, but I think my implementation is correct. Here is what this CustomSwitchPreference looks like :
When I test all this in my app, everything is fine only if
notifyChanged()
and/ornotifyDependencyChanged()
are not called in methodsetChecked(boolean checked)
. If one of these notification methods is called, the SwitchButton starts to misbehave :true
tofalse
, the state changes immediately even if the SwitchButton is set to have an animation during transition.false
totrue
, nothing happens... but in fact, internally, the state has changed.true
).I have tried many workaround, but cannot find one to fix this.
As the behavior is not the same depending on the state of the SwitchButton, I suspect that internally something is managed differently when the UI of the Preferences objects is updated.
I hope you could have a look at this and try to reproduce the case. Using the SwitchButton in Preferences is something quite normal and natural, but it is then important that the Switch behaves as expected when
notifyChanged()
ornotifyDependencyChanged()
are called.Thanks in advance!
The text was updated successfully, but these errors were encountered: