How to use custom views, e.g. setting drawable
<p>I think I'm a bit confused about how to use custom views. I'm following along with slides from a talk given by Eric Burke from Square (from this year's anddevcon, slides here: <a href="http://www.andevcon.com/AndevCon_II/downloadpresentation.aspx?aid=Taming_Android__User_Experience_Lessons_from_Square_pdf.zip&amp;sid=2" rel="nofollow">http://www.andevcon.com/AndevCon_II/downloadpresentation.aspx?aid=Taming_Android__User_Experience_Lessons_from_Square_pdf.zip&amp;sid=2</a>). </p>

<p>His code, or at least the part he showed in the slides, went something like this:</p>

<pre><code>public class EditablePhoto extends View {

    private Bitmap framedPhoto;
    private Bitmap image;
    private Drawable placeholder;

    public EditablePhoto(Context context) {
        super(context);
    }

    @Override protected void onMeasure(int widthMeasureSpec,
                                       int heightMeasureSpec) {
        int measuredWidth = getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec);
        int measuredHeight = getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec);

        //ensure view always square
        int min = Math.min(measuredHeight, measuredWidth);
        setMeasuredDimension(min, min);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        if(placeholder == null &amp;&amp; image==null) return;

        if(framedPhoto == null) {
            createFramedPhoto(Math.min(getWidth(), getHeight()));
        }

        canvas.drawBitmap(framedPhoto, 0, 0, null);
    }

    private void createFramedPhoto(int size) {

        Drawable imageDrawable = (image!=null)
                ? new BitmapDrawable(image) : placeholder;

        Bitmap output = Bitmap.createBitmap(size, size, 
                Bitmap.Config.ARGB_8888);

        Canvas canvas = new Canvas(output);

        RectF outerRect = new RectF(0, 0, size, size);
        float outerRadius = size / 18f;

        //Red rectangle

        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setColor(Color.RED);

        canvas.drawRoundRect(outerRect, outerRadius, outerRadius, paint);

        paint.setXfermode(new PorterDuffXfermode(
                PorterDuff.Mode.SRC_IN));

         imageDrawable.setBounds(0, 0, size, size);
        canvas.saveLayer(outerRect, paint, Canvas.ALL_SAVE_FLAG);
        imageDrawable.draw(canvas);
        canvas.restore();
    }
}
</code></pre>

<p>What I don't get is how to actually use this View now.... Where and when do you set the bitmaps, which are private fields in this class...?</p>

<p>Generally confused and would love some enlightenment. </p>
