嵌套的PreferenceScreens的自定义PreferenceActivity布局丢失 [英] Custom PreferenceActivity Layout is lost for nested PreferenceScreens

查看:234
本文介绍了嵌套的PreferenceScreens的自定义PreferenceActivity布局丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个首选项活动,该活动从以下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文件重新加载首选项来解决(消除)此问题.

解决方案

我相信这是

However when open a nested PreferenceScreen inside it reverts to the showing just a listview, is there a simple way to keep the layout the same between the preference screens?

I tried PreferenceScreen.setLayoutResource(R.id.layout.main); but that just changes the view displayed before it is opened

Update

I fixed (Kludged) this by changing the nested PreferenceScreens into normal preferences and overriding their onclick methods to clear the preferences from the listview and reload the preferences from an appropriate XML file.

解决方案

I believe that this is another symptom of the bug described here A work around is to reset the layout each time a preference screen is opened.

这篇关于嵌套的PreferenceScreens的自定义PreferenceActivity布局丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆