【发布时间】:2011-01-27 21:16:37
【问题描述】:
我有一个偏好活动,它从以下 XML 获取它的布局。这会在首选项的底部显示一个按钮。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.stealthcopter.nexus.nexusgl"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView android:id="@android:id/list"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<Button android:text="This is a button on top of all preferences."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
但是,当打开一个嵌套的 PreferenceScreen 时,它会恢复为仅显示一个列表视图,有没有一种简单的方法可以保持首选项屏幕之间的布局相同?
我试过 PreferenceScreen.setLayoutResource(R.id.layout.main);但这只会改变打开之前显示的视图
更新
我通过将嵌套的 PreferenceScreens 更改为普通首选项并覆盖其 onclick 方法以从列表视图中清除首选项并从适当的 XML 文件重新加载首选项来修复(Kludged)此问题。
【问题讨论】:
标签: android preferences preferencescreen