更改ListPreference样式

5
我想通过创建一个新的样式来更改ListPreference的默认图像。
我已经通过继承Widget.CompoundButton.CheckBox并设置一个新的android:button来模仿CheckBoxPreference,但是我不知道如何在ListPreference上做到这一点。
1个回答

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" />

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接