Tuesday, December 11, 2012

Detect Android Application In Edit Mode

Sometimes we have to know when your code is running in the editor.

When authoring a control, it's common to include code that must run outside the editor, otherwise it would cause an exception in edit mode.

The following code shows how to do it:
public class YourControl extends FrameLayout {
    public YourControl (Context context, AttributeSet attrs) {
        super(context, attrs);

        if (!isInEditMode()) {
            //code to run outside the editor
        }
}

No comments:

Post a Comment