Question

I am trying to rewrite my PreferenceActivity to use Preference-Headers I followed the official docs but My Headers are not showing for some reason. I just get a blank screen.

Here's my XML:

<?xml version="1.0" encoding="utf-8"?>
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
    <preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
        <header
                android:fragment="com.mikebdev.refuel.SettingsActivity$DesignFragment"
                android:title="@string/pref_header_design"
                android:summary="@string/pref_header_design_summary"
                />
        <header
                android:fragment="com.mikebdev.refuel.SettingsActivity$SettingsFragment"
                android:title="@string/pref_header_units"
                android:summary="@string/pref_header_units_summary"/>
        <header
                android:fragment="com.mikebdev.refuel.SettingsActivity$DatabaseFragment"
                android:title="@string/pref_header_db"
                android:summary="@string/pref_header_db_summary"/>
    </preference-headers>
</preference-headers>

And heres My SettingsActivity:

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Environment;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.widget.Toast;

import com.google.analytics.tracking.android.EasyTracker;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

public class SettingsActivity extends PreferenceActivity {

    public static final String PREFS_NAME = "RFPref";
    public static PreferenceManager prefMgr;



    @Override
    public void onBuildHeaders(List<Header> target) {
        loadHeadersFromResource(R.xml.pref_headers, target);
    }
}

I am going to leave out the inner PreferenceFragment classes..

What am I doing wrong?

Was it helpful?

Solution

You have redundant <preference-headers> elements. Get rid of the inner one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top