1

In my app exist my own class

public class ColorAccesoryView extends View{
    @Override protected void onDraw(Canvas cv){
    }
}

used in layout color_accesory.xml

<?xml version="1.0" encoding="utf-8"?>
<android.swp.ColorAccesoryView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/color_box"
android:layout_width="52dp"
android:layout_height="26dp"
android:gravity="right"
android:paddingRight="12dp" />

While PreferenceScreen create, I set this xml as a widget in two different preferences

color1_Pref.setWidgetLayoutResource(R.layout.color_accesory);
...
color2_Pref.setWidgetLayoutResource(R.layout.color_accesory);

How to get access to two instances of ColorAccesoryView to setup it for each preference separatelly?

theWalker
  • 2,022
  • 2
  • 18
  • 27

1 Answers1

0

Try wrap your layout color_accesory.xml in group view element:

    <FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

        <android.swp.ColorAccesoryView 
            android:id="@+id/color_box"
            android:layout_width="52dp"
            android:layout_height="26dp"
            android:gravity="right"
            android:paddingRight="12dp" />
</FrameLayout>
miha_dev
  • 161
  • 4
  • OK but question is: How to get access to two instances of ColorAccesoryView to setup it for each preference separatelly? – theWalker Feb 08 '16 at 10:30