1 package org.robolectric.android; 2 3 import android.content.Context; 4 import android.util.AttributeSet; 5 import android.widget.TextView; 6 7 public class CustomStateView extends TextView { 8 9 public Integer extraAttribute; 10 CustomStateView(Context context)11 public CustomStateView(Context context) { 12 super(context); 13 } 14 CustomStateView(Context context, AttributeSet attrs)15 public CustomStateView(Context context, AttributeSet attrs) { 16 super(context, attrs); 17 } 18 CustomStateView(Context context, AttributeSet attrs, int defStyle)19 public CustomStateView(Context context, AttributeSet attrs, int defStyle) { 20 super(context, attrs, defStyle); 21 } 22 23 @Override onCreateDrawableState(int extraSpace)24 protected int[] onCreateDrawableState(int extraSpace) { 25 final int[] drawableState = super.onCreateDrawableState(extraSpace + 1); 26 if (extraAttribute != null) { 27 mergeDrawableStates(drawableState, new int[] {extraAttribute}); 28 } 29 return drawableState; 30 } 31 } 32