Browse Source

add setter for inputlayout error

pull/45/head
Thodoris1999 6 years ago
parent
commit
e139bd27e0
  1. 9
      app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java
  2. 3
      app/src/main/res/layout/editor_view.xml

9
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<String> 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);
}

3
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">
<!--bold, italic, etc buttons-->
<android.support.v7.widget.AppCompatImageButton
android:id="@+id/bold_button"

Loading…
Cancel
Save