How to use isInEditMode() to see layout with custom View in the editor

isInEditMode()should be used inside the Custom View constructor.
Try the following code:

     public class GraphView extends View implements Grapher
        {

         public GraphView(Context context, AttributeSet attrs) {
                super(context, attrs);
                if(!isInEditMode())
                 init(context);
            }

            public GraphView(Context context) {
                super(context);
               if(!isInEditMode()){
                touchHandler = new TouchHandler(this);
                init(context);
              }
            }

Leave a Comment