开发者

Custom PreferenceActivity Layout is lost for nested PreferenceScreens

开发者 https://www.devze.com 2023-02-07 16:50 出处:网络
I have a preference activity which gets it\'s layout from the following XML. This makes a button appear at the bottom of the preferences.

I have a preference activity which gets it's layout from the following XML. This makes a button appear at the bottom of the preferences.

<LinearLayout xmlns:android="http://schemas.android.c开发者_运维知识库om/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>

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.


What are you trying to achieve with the custom preference screen? The is no preference to take into account here? I also I'm pretty sure that preference layout have to be in a 'xml' folder not the 'layout'

0

精彩评论

暂无评论...
验证码 换一张
取 消