Code example for TouchDelegate

0
            setTouchDelegate(mTouchDelegateGroup);
        } 
    } 
 
    private void addTouchDelegate(Rect rect, int color, View delegateView) {
        mTouchDelegateGroup.addTouchDelegate(new TouchDelegate(rect, delegateView));
        mTouchDelegateRecords.add(new TouchDelegateRecord(rect, color));
    } 
 
    @Override 
    protected void dispatchDraw(Canvas canvas) {
        for (TouchDelegateRecord record : mTouchDelegateRecords) {
            mPaint.setColor(record.color);
            canvas.drawRect(record.rect, mPaint);
        } 
        super.dispatchDraw(canvas);
    } 
 
    /** 
     * Register a listener to be notified of changes on this item view. 
     *