简体   繁体   English

更改ListPreference样式

[英]Change ListPreference style

I want to change default image of a ListPreference by creating a new style . 我想通过创建一个新style来更改ListPreference的默认图像。

I did it with a CheckBoxPreference by inherit Widget.CompoundButton.CheckBox and setting a new android:button , but I don't know how to do it on a ListPreference . 我通过继承Widget.CompoundButton.CheckBox并设置一个新的android:buttonCheckBoxPreference Widget.CompoundButton.CheckBox了,但我不知道如何在ListPreference上做到这ListPreference

You can add an icon in the preference using the WidgetLayout property. 您可以使用WidgetLayout属性在首选项中添加图标。

Example: 例:

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

And the mode_item_preference.xml 和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" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM