3

I have searched the forums, but can't seem to figure out how to show a title bar in the Android Preferences Fragment. I see questions about how to hide it, but not about how to show it.

I have a preferences activity

public class SettingsActivity extends PreferenceActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getFragmentManager().beginTransaction().replace(android.R.id.content,new SettingsFragment()).commit();
    }
}

And I have a preferences fragment:

public class SettingsFragment extends PreferenceFragment {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences);
    }
}

And I have a preferences xml:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <PreferenceCategory
        android:title="@string/title">
        <CheckBoxPreference
            android:key="regular"

However there is no title bar at the top of the preferences screen. Any ideas how to make one show?

BenW
  • 101
  • 12

1 Answers1

-2

You mean show title bar in the fragment?
you can try to inherit AppCompatActivity.

Gordon
  • 65
  • 1
  • 3