1

I am working on a Xposed module and I need to have an icon beside each item in my List Preferences. I am able to do this :

http://s20.postimg.org/gjveleu5p/Screenshot_2014_01_18_16_47_38.png

But I want exactly like This one :

http://s20.postimg.org/ee13qwqp9/Screenshot_2014_01_29_12_32_38.png

My Java Class File:

package ic.lunar.xposed.exthemer.list.preferences;

import ic.lunar.xposed.exthemer.R;
import android.content.Context;
import android.preference.ListPreference;
import android.util.AttributeSet;

public class Sim_Icon_List_Preference extends ListPreference {

Context context;

public Sim_Icon_List_Preference(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.context = context;
    setDialogLayoutResource(R.layout.activity_my_list_preference); //inherited from DialogPreference
}
}

My Layout Xml File:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context=".MyListPreference" >
<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:src="@drawable/tw_sim_icon_home" />
<ImageView
    android:id="@+id/imageView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/imageView1"
    android:layout_toRightOf="@+id/imageView1"
    android:src="@drawable/tw_sim_icon_heart" />
</RelativeLayout>
Cœur
  • 37,241
  • 25
  • 195
  • 267
Lunar Inc.
  • 13
  • 1
  • 7

1 Answers1

0

When you need a ListPreference with (per row) a text and an icon, you can find a solution via this description.

Community
  • 1
  • 1
tm1701
  • 7,307
  • 17
  • 79
  • 168