diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java b/app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java index 69de150b..94b9090f 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java @@ -4,6 +4,7 @@ import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.res.TypedArray; +import android.support.annotation.Nullable; import android.support.design.widget.TextInputEditText; import android.support.design.widget.TextInputLayout; import android.support.v7.widget.AppCompatImageButton; @@ -26,6 +27,7 @@ public class EditorView extends LinearLayout { private SparseArray colors = new SparseArray<>(); + private TextInputLayout edittextWrapper; private TextInputEditText editText; private AppCompatImageButton emojiButton; private AppCompatImageButton submitButton; @@ -51,11 +53,12 @@ public class EditorView extends LinearLayout { LayoutInflater.from(context).inflate(R.layout.editor_view, this, true); setOrientation(VERTICAL); + edittextWrapper = findViewById(R.id.editor_edittext_wrapper); editText = findViewById(R.id.editor_edittext); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.EditorView, 0, 0); try { - ((TextInputLayout) findViewById(R.id.editor_edittext_wrapper)).setHint(a.getString(R.styleable.EditorView_hint)); + edittextWrapper.setHint(a.getString(R.styleable.EditorView_hint)); } finally { a.recycle(); } @@ -235,6 +238,10 @@ public class EditorView extends LinearLayout { editText.setText(text); } + public void setError(@Nullable CharSequence text) { + edittextWrapper.setError(text); + } + public void setOnSubmitListener(OnClickListener onSubmitListener) { submitButton.setOnClickListener(onSubmitListener); } diff --git a/app/src/main/res/layout/editor_view.xml b/app/src/main/res/layout/editor_view.xml index aa0098b2..9003deb5 100644 --- a/app/src/main/res/layout/editor_view.xml +++ b/app/src/main/res/layout/editor_view.xml @@ -8,7 +8,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" - app:columnWidth="36dp"> + app:columnWidth="36dp" + android:background="@color/card_background">