使用Preference-Headers重寫PreferenceActivity。但是按照步驟操作之後header沒顯示,白屏。
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>
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);
}
}
不知道哪裡出問題?
找到原因了,是冗雜的元素引起的,去掉裡面的就好了。