【问题标题】:Android settings change when scrolling滚动时Android设置发生变化
【发布时间】:2015-03-07 05:38:52
【问题描述】:

我有一个非常标准的 PreferenceFragment,它是使用 FragmentActivity 实现的。没什么特别的,但我有一些(少数)人使用该应用程序报告说,当他们滚动设置时,有些人会随机关闭或打开自己。定义很简单:1下面

    <SwitchPreference
        android:key="speechEnabled"
        android:persistent="true"
        android:defaultValue="true"
        android:title="some title"
        android:summary="summary text" />

这是一个报告问题的人的视频:

https://drive.google.com/file/d/0Bx67XBdVKhrKUDVJS24zWmtUa1k/view?usp=sharing

【问题讨论】:

  • 请发布您的 PreferenceFragment 代码。

标签: android preferencefragment switchpreference


【解决方案1】:

没有看到代码很难说出任何事情,但我遇到了一个问题,即在纵向/横向更改时重新创建 Activity。
为了修复它,我在 Activity 的清单中添加了android:configChanges="orientation",如下所示:

<activity android:name="com.example.app.ExampleActivity" android:theme="@android:style/Theme.NoTitleBar" android:configChanges="orientation" >
</activity>

您可能还需要致电setRetainInstance,有关更多信息,请参阅此帖子: android:configChanges="orientation" does not work with fragments

【讨论】:

    猜你喜欢
    • 2013-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-22
    • 2014-10-27
    相关资源
    最近更新 更多