title: Android: my custom spinner-item works, but not correct on Lollipop - why?
body: <p>I have a problem.</p>
  
  <p>I made a custom spinner-item, which shows a text and a image.</p>
  
  <p>this works on my devices: Android 2.3.7 and 4.0.4 - it shows the text and the image.</p>
  
  <p>but doesn't work on my device: Android 5.0.2 - it shows only the text, without the image.</p>
  
  <p>i don't get the reason why.. somebody an idea?</p>
  
  <p>--</p>
  
  <p>my Java-Code:</p>
  
  <pre><code> SimpleCursorAdapter adapter = new SimpleCursorAdapter(
              getActivity(),
              R.layout.spinner_item,
              MainActivity.db.getList(),
              new String[]{DatabaseHandler.ENTRY_LANGUAGE.NAME, DatabaseHandler.ENTRY_LANGUAGE.TTS},
              new int[]{R.id.text, R.id.sound},
              0);
  
      adapter.setDropDownViewResource(R.layout.spinner_item);
      adapter.setViewBinder(new MyViewBinder());
      final Spinner spinner = (Spinner) view.findViewById(R.id.mlang);
      spinner.setAdapter(adapter);
  </code></pre>
  
  <p>my spinner_item.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;com.example.app.common.CheckedRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="50dp"
      android:background="@color/spinner_bg"&gt;
  
  
      &lt;CheckedTextView
          android:id="@+id/text"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerVertical="true"
          android:paddingLeft="13dp"
          android:textAppearance="?android:attr/textAppearanceMedium"
          android:textColor="@drawable/spinner_selected_text"
          android:textSize="18sp" /&gt;
  
          &lt;ImageView
              android:id="@+id/sound"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentRight="true"
              android:layout_centerVertical="true"
              android:paddingRight="8dp"
              android:src="@drawable/speaker" /&gt;
  
  &lt;/com.example.app.common.CheckedRelativeLayout&gt;
  </code></pre>
  
  <p>my CheckedRelativeLayout:</p>
  
  <pre><code>package com.example.app.common;
  
  import android.annotation.SuppressLint;
  import android.content.Context;
  import android.util.AttributeSet;
  import android.view.View;
  import android.widget.Checkable;
  import android.widget.RelativeLayout;
  
  public class CheckedRelativeLayout extends RelativeLayout implements Checkable {
  
      private static final int[] CHECKED_STATE_SET = {
          android.R.attr.state_checked
      };
  
      private boolean checked = false;
  
      @SuppressLint("NewApi")
      public CheckedRelativeLayout(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
      }
  
      public CheckedRelativeLayout(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      public CheckedRelativeLayout(Context context) {
          super(context);
      }
  
      @Override
      public boolean isChecked() {
          return checked;
      }
  
      @Override
      public void setChecked(boolean checked) {
          this.checked = checked;
  
          refreshDrawableState();
  
          //Propagate to childs
          final int count = getChildCount();
          for (int i = 0; i &lt; count; i++) {
              final View child = getChildAt(i);
              if(child instanceof Checkable) {
                  ((Checkable)child).setChecked(checked);
              }
          }
      }
  
      @Override
      protected int[] onCreateDrawableState(int extraSpace) {
          final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
          if (isChecked()) {
              mergeDrawableStates(drawableState, CHECKED_STATE_SET);
          }
          return drawableState;
      }
  
      @Override
      public void toggle() {
          this.checked = !this.checked;
      }
  
  }
  </code></pre>