Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get Android PreferenceFragment title/header to show in right pane?
    primarykey
    data
    text
    <p>I am creating a PreferenceActivity for a tablet app (Android 3.0+) using PreferenceFragments. The goal is to have a two-pane layout displaying the preferences just like the system preferences are displayed. </p> <p>The issue I'm having is that I cannot for the life of me seem to get the title of the currently selected PreferenceFragment to display above the ListView of the PreferenceFragment in the right pane. Here is an example of what I'm trying to do (trying to display the content in red box.)</p> <p><img src="https://i.stack.imgur.com/SHnbv.png" alt="enter image description here"> Here is my preference_headers.xml file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;preference-headers xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;header android:fragment="com.mycompany.mobile.preferences.MyPreferencesActivityHC$GeneralSettingsPreferenceFragment" android:title="General Settings"&gt; &lt;/header&gt; &lt;header android:fragment="com.mycompany.mobile.preferences.MyPreferencesActivityHC$PhotoOptionsPreferenceFragment" android:title="Photo Settings" android:summary="Testing photo settings"&gt; &lt;/header&gt; &lt;/preference-headers&gt; </code></pre> <p>and here is the code for MyPreferencesActivity.java</p> <pre><code>package com.mycompany.mobile.preferences; import java.util.List; import android.content.Intent; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.PreferenceFragment; import com.mycompany.mobile.R; public class MyPreferencesActivityHC extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTitle(R.string.taskCaptionSettings); } @Override public void onBuildHeaders(List&lt;Header&gt; target) { loadHeadersFromResource(R.xml.preference_headers, target); } public static class GeneralSettingsPreferenceFragment extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.general_settings_preferences); } } public static class PhotoOptionsPreferenceFragment extends PreferenceFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.photo_options_preferences); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload