I'm developing an app that sends messages depending of the categories you are subscribed.
To do so, I have implemented a PreferenceActivity
where I add dynamically a SwitchPreference
for each category as showed at the picture below.
The problem is that when I change the switches status, scroll down and then scroll up they go back to default status by their own.
Did anybody have the same problem?
This behaviour is caused by an Android bug for earlier versions of android 5 Lollipop.
If you are developing for Android 4.X or below, you have two options:
1 - Develop a custom SwitchPreference
2 - Use Checkboxes
instead.
To do so, see this question related.