Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom PreferenceCategory Headings
    text
    copied!<p>I have a simple preference screen defined like this</p> <pre><code>&lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;PreferenceCategory android:title="Security"&gt; &lt;CheckBoxPreference android:title="Require Pin on Start" android:summary="Require pin to run the application" android:key="@string/pref_require_pin" android:defaultValue="false" /&gt; &lt;/PreferenceCategory&gt; &lt;PreferenceCategory android:title="Settings"&gt; &lt;ListPreference android:title="History Age (in days)" android:summary="Display items up to 30 days old" android:key="@string/pref_history_days" android:defaultValue="30" android:entries="@array/days_list" android:entryValues="@array/days_list" android:dialogTitle="Select History Age"/&gt; &lt;/PreferenceCategory&gt; &lt;/PreferenceScreen&gt; </code></pre> <p>I have a style setup already and used elsewhere in my app.</p> <pre><code>&lt;style name="ListHeader"&gt; &lt;item name="android:textColor"&gt;#000000&lt;/item&gt; &lt;item name="android:textStyle"&gt;bold&lt;/item&gt; &lt;item name="android:textSize"&gt;12sp&lt;/item&gt; &lt;item name="android:background"&gt;#cccccc&lt;/item&gt; &lt;item name="android:paddingTop"&gt;6px&lt;/item&gt; &lt;item name="android:paddingBottom"&gt;6px&lt;/item&gt; &lt;item name="android:paddingLeft"&gt;12px&lt;/item&gt; &lt;/style&gt; </code></pre> <p>and here is my activity</p> <pre><code>public class PreferencesActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.layout.preferences); } } </code></pre> <p>How do I apply my custom style to the <code>PreferenceCategory</code> heading?</p>
 

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