Preference screen display text block

Nick picture Nick · Aug 9, 2012 · Viewed 19.8k times · Source

I am trying to make a Preference screen that just has an about, contact, and legal option, all of which when clicked just show text blurb and icon in a separate page, no shared preferences or anything.

I am having trouble understanding the hierarchy in order to display the text. I would like the flow to be: settings -> about -> the about text

Currently I have this, which gives me the category and option, but I don't know what to make it in order to display new text.

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

    <PreferenceCategory
            android:title="Info">
        <Preference android:title="About"/>


    </PreferenceCategory>
...
</PreferenceScreen>

I don't know what option to use to make the about clickable into a textview.

Answer

Krzysiek picture Krzysiek · Oct 30, 2014

A.Grandt's solution gives really nice imitation of text block within Preference Activity, but I would add an android:persistent="false" attribute, which avoids storing unnecessarily this 'pseudo preference' into SharedPreferences file for your app's settings.

To sum up. Imitation of TextView within Preferences Activity as A.Grandt suggested would be:

<Preference
    android:key="pref_static_field_key"
    android:selectable="false"
    android:persistent="false"
    android:title="you can omit the title"
    android:summary="Multi line description\ncan go here."/>

Although you can use \n for line breaking, yet it won't resize the Preference Item itself, so there is a possibility that these multilines will not be fully visible within a still single-line Preference Item.