diff --git a/library/src/main/java/com/github/ahmadaghazadeh/editor/widget/CodeEditor.java b/library/src/main/java/com/github/ahmadaghazadeh/editor/widget/CodeEditor.java index 48a10eb..1b8c6b4 100644 --- a/library/src/main/java/com/github/ahmadaghazadeh/editor/widget/CodeEditor.java +++ b/library/src/main/java/com/github/ahmadaghazadeh/editor/widget/CodeEditor.java @@ -109,7 +109,7 @@ public static void setCodeView(CodeEditor view, MutableLiveData code, Mu private void init(Context context, AttributeSet attrs) { try { - removeAllViews(); + this.context = context; initEditor(); String code = ""; @@ -132,6 +132,7 @@ private void init(Context context, AttributeSet attrs) { RelativeLayout.LayoutParams rootViewParam = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); rootView = new RelativeLayout(context); + rootView.removeAllViews(); rootView.setLayoutParams(rootViewParam); GutterView gutterView = new GutterView(context); gutterView.setId(R.id.gutterView);