user728887
user728887

Reputation:

Android Preference Layout questions

I would like to make something like this http://goo.gl/km9T7Z

My codes looks like this

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
        xmlns:android="http://schemas.android.com/apk/res/android">


  <PreferenceCategory android:key="aaa"
        android:title="">
        <PreferenceScreen android:title="@string/bbb"
             android:key="ccc" />
        <PreferenceScreen android:title="@string/ddd"
             android:key="eee" />
  </PreferenceCategory>
  <PreferenceCategory android:key="fff"
        android:title="">
        <CheckBoxPreference android:key="ggg"
            android:title="@string/hhh"
            android:defaultValue="true" 
            android:summary="" />
        <CheckBoxPreference android:key="iii"
            android:title="@string/jjj"
            android:defaultValue="true" 
            android:summary="" />   
  </PreferenceCategory>

</PreferenceScreen>   

how can I make the background gray and something like the ">"? thanks so much for the help

Upvotes: 0

Views: 88

Answers (2)

Mani
Mani

Reputation: 231

You can get that ">" symbol for ListPreference

preference.xml

<PreferenceCategory 
    android:title="@string/category1"

    >

    <ListPreference
        android:key="pref_key"
        android:title="@string/pref_title"
        android:summary="@string/pref_summary"
        android:entries="@array/pref_list"
        android:entryValues="@array/pref_values"
        android:defaultValue="50"
        />



</PreferenceCategory>

string.xml

these for showing a title and sub title for list of items

<string name="pref_tile">Preference Title</string>
<string name="pref_summary">Current pref value is:</string>

arrays.xml

names of item to display in list and respective values for each item

<string-array name="pref_list">
    <item>Item1</item>
    <item>Item2</item>
    <item>Item3</item>
    <item>Item4</item>

</string-array>
<string-array name="pref_values">
    <item>1</item>
    <item>2</item>
    <item>3</item>
    <item>4</item>

</string-array>

Upvotes: 1

myanimal
myanimal

Reputation: 3620

For each Preference you can set a custom layout using android:layout="@layout/pref_item".

In that layout you can use a LinearLayout with a TextView and ImageView to get the desired look.

Upvotes: 1

Related Questions