I could not dig out the cause for that particular behavior, but following apparently fixes the issue:
- Remove
onCreateView()
. - Add fragment_preference.xml layout directly to the preference.xml.
preference.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_syncing_wifi"
android:title="123" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_syncing_carrier"
android:title="234" />
<Preference android:layout="@layout/fragment_preference" />
</PreferenceScreen>
Also, no such behavior is observed with CheckBoxPreference
.
Hope this helps.