FileDocCategorySizeDatePackage
ViewAttachView.javaAPI DocAndroid 5.1 API2379Thu Mar 12 22:22:12 GMT 2015android.view

ViewAttachView

public class ViewAttachView extends android.view.View
A View that will throw a RuntimeException if onAttachedToWindow and onDetachedFromWindow is called in the wrong order for ViewAttachTest

Fields Summary
public static final String
TAG
private boolean
attached
Constructors Summary
public ViewAttachView(android.content.Context context, android.util.AttributeSet attrs, int defStyle)


           
        super(context, attrs, defStyle);
        init(attrs, defStyle);
    
public ViewAttachView(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
        init(attrs, 0);
    
public ViewAttachView(android.content.Context context)

        super(context);
        init(null, 0);
    
Methods Summary
private voidinit(android.util.AttributeSet attrs, int defStyle)

        SystemClock.sleep(2000);
    
protected voidonAttachedToWindow()

        Log.d(TAG, "onAttachedToWindow");
        super.onAttachedToWindow();
        if (attached) {
            throw new RuntimeException("OnAttachedToWindow called more than once in a row");
        }
        attached = true;
    
protected voidonDetachedFromWindow()

        Log.d(TAG, "onDetachedFromWindow");
        super.onDetachedFromWindow();
        if (!attached) {
            throw new RuntimeException(
                    "onDetachedFromWindowcalled without prior call to OnAttachedToWindow");
        }
        attached = false;
    
protected voidonDraw(android.graphics.Canvas canvas)

        super.onDraw(canvas);
        canvas.drawColor(Color.BLUE);