Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change ListPreference style

I want to change default image of a ListPreference by creating a new style.

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.

like image 309
SxEdge Avatar asked Nov 14 '22 01:11

SxEdge


1 Answers

You can add an icon in the preference using the WidgetLayout property.

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

<?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" />
like image 196
Sigrist Avatar answered Dec 17 '22 03:12

Sigrist