From 63ad3a7a15ad082a644c2d7a8629930c54f1f8ea Mon Sep 17 00:00:00 2001 From: Ahmad Aghazadeh Date: Fri, 5 Oct 2018 22:20:55 +0330 Subject: [PATCH] Fix Fragment bug --- .../com/github/ahmadaghazadeh/editor/widget/CodeEditor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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);