FileDocCategorySizeDatePackage
ColorPickerSwatch.javaAPI DocAndroid 5.1 API2695Thu Mar 12 22:22:50 GMT 2015com.android.colorpicker

ColorPickerSwatch

public class ColorPickerSwatch extends android.widget.FrameLayout implements View.OnClickListener
Creates a circular swatch of a specified color. Adds a checkmark if marked as checked.

Fields Summary
private int
mColor
private android.widget.ImageView
mSwatchImage
private android.widget.ImageView
mCheckmarkImage
private OnColorSelectedListener
mOnColorSelectedListener
Constructors Summary
public ColorPickerSwatch(android.content.Context context, int color, boolean checked, OnColorSelectedListener listener)

        super(context);
        mColor = color;
        mOnColorSelectedListener = listener;

        LayoutInflater.from(context).inflate(R.layout.color_picker_swatch, this);
        mSwatchImage = (ImageView) findViewById(R.id.color_picker_swatch);
        mCheckmarkImage = (ImageView) findViewById(R.id.color_picker_checkmark);
        setColor(color);
        setChecked(checked);
        setOnClickListener(this);
    
Methods Summary
public voidonClick(android.view.View v)

        if (mOnColorSelectedListener != null) {
            mOnColorSelectedListener.onColorSelected(mColor);
        }
    
private voidsetChecked(boolean checked)

        if (checked) {
            mCheckmarkImage.setVisibility(View.VISIBLE);
        } else {
            mCheckmarkImage.setVisibility(View.GONE);
        }
    
protected voidsetColor(int color)

        Drawable[] colorDrawable = new Drawable[]
                {getContext().getResources().getDrawable(R.drawable.color_picker_swatch)};
        mSwatchImage.setImageDrawable(new ColorStateDrawable(colorDrawable, color));