2

我有一个带有多个 SwitchPreferences 的 PreferencesFragment。

在极少数平板电脑上。我看到当开关设置为关闭并且用户将其更改为打开时发生的问题,然后向下滚动将 SwitchPreference 移出屏幕。当用户向上滚动时,开关已恢复为关闭状态。

例如,在下图中。如果用户将“启用背景”设置为开,则向下滚动。然后备份。“启用背景”将再次关闭。有谁知道为什么偶尔会发生这种情况。

设置

这是该特定 SwitchPrefence 的 xml

<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>

偏好片段

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
    }
}
}
4

1 回答 1

4

Turns out this is actually a google bug.

Issue reported here

于 2013-11-16T07:56:34.333 回答