I have a custom EditText
declared in an XML file and I'm including it like so:
<include layout="@layout/my_edit_text"
android:id="@+id/passwordField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/passwordHint"
android:inputType="textPassword" />
and here is my_edit_text.xml
:
<?xml version="1.0" encoding="utf-8"?>
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="0dp"
android:textColor="@color/gray"
android:textSize="@dimen/editTextFontSize"
android:padding="@dimen/editTextPadding"
android:background="@drawable/edit_text_background"
android:ellipsize="end" />
However, I can't set the hint
or inputType
this way, for some reason. If I set it in my_edit_text.xml
, it works fine, but I would like to be able to set each reference individually.
The reason that I have the custom EditText
is to avoid having to rewrite all of the common values in every one of my EditText
s.
Do I have to do something similar to what this person has? If I do, will I need to actually build a .java subclass and extract the attributes that way? That just seems excessive.