2012-07-25 56 views
5

我想通过创建新的style更改ListPreference的默认图像。更改列表偏好样式

我有CheckBoxPreference通过继承Widget.CompoundButton.CheckBox和设置新的android:button做到了,但我不知道如何做到这一点上ListPreference

回答

1

您可以使用WidgetLayout属性在首选项中添加图标。

实施例:

<EditTextPreference 
    android:defaultValue="" 
    android:dialogTitle="@string/mode_name" 
    android:key="mode_name" 
    android:order="0" 
    android:summary="" 
    android:title="@string/mode_name" 
    android:widgetLayout="@layout/mode_item_preference" 
    /> 

而mode_item_preference.xml

<?xml version="1.0" encoding="utf-8"?> 
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:contentDescription="@string/app_name" 
    android:focusable="false" 
    android:src="@drawable/delete" />