问题
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.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>
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.
回答1:
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.
回答2:
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'
来源:https://stackoverflow.com/questions/4821969/custom-preferenceactivity-layout-is-lost-for-nested-preferencescreens