I have a PreferencesFragment with several SwitchPreferences.
On a very few tablets. I'm seeing an issue that occurs when a switch is set to off and the user changes them to on, then scrolls down moving the SwitchPreference offscreen. When the user scrolls back up the switch has reverted back to off.
As an example, in the following picture. If the user sets "Enable Backdrops" to on, then scrolls down. Then back up. "Enable Backdrops" will be off again. Does anyone know why this is happening on the occasional device.
Here is the xml for that particular SwitchPrefence
<PreferenceCategory
android:title="General"
android:key="pref_general_settings">
<SwitchPreference
android:key="pref_enable_backdrops"
android:title="Enable Backdrops"
android:summaryOff="Backdrops are not shown in various views"
android:summaryOn="Backdrops are shown in various views"
android:defaultValue="false" />
<SwitchPreference
android:key="pref_include_trailers"
android:title="Include Trailers"
android:summaryOff="Trailers will not be included in search results, the homescreen, and actor bio screens"
android:summaryOn="Trailers will be included in search results, the homescreen, and actor bio screens"
android:defaultValue="false" />
</PreferenceCategory>
The PreferencesFragment
public class MainSettingsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
try {
FileUtils fileUtils = new FileUtils();
ServerInfo serverInfo = fileUtils.LoadLastConnected(getActivity());
if (serverInfo != null) {
if (serverInfo.FriendlyName != null && !serverInfo.FriendlyName.isEmpty())
this.findPreference("pref_server_name").setTitle(serverInfo.FriendlyName);
else
this.findPreference("pref_server_name").setTitle(serverInfo.HostNameOrIpAddress);
}
} catch (Exception e) {
// Do Something
}
}
}