Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在多个EditText字段中显示Drawable_Java_Android_Android Layout_User Interface_Android Edittext - Fatal编程技术网

Java 在多个EditText字段中显示Drawable

Java 在多个EditText字段中显示Drawable,java,android,android-layout,user-interface,android-edittext,Java,Android,Android Layout,User Interface,Android Edittext,我正在尝试为我的应用程序创建注册页面,但我无法在所有已正确填写的edittext字段中显示可绘制的“记号”。当前,drawable仅显示在最后一个ConfirmPassword编辑文本中,而不是其他文本中,尽管它们基本上具有相同的代码。这是我的XML文件- <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:

我正在尝试为我的应用程序创建注册页面,但我无法在所有已正确填写的edittext字段中显示可绘制的“记号”。当前,drawable仅显示在最后一个ConfirmPassword编辑文本中,而不是其他文本中,尽管它们基本上具有相同的代码。这是我的XML文件-

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorPrimary"
android:theme="@style/LoginActivityStyle"
android:fitsSystemWindows="true"
tools:context=".RegisterActivity">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="48dp"
    android:paddingLeft="24dp"
    android:paddingRight="24dp">

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:layout_gravity="center_horizontal"
        android:scaleType="fitCenter"
        android:tint="@android:color/white"
        android:scaleX="2.7"
        android:scaleY="2.7"
        android:src="@drawable/ic_interact_logo" />

    <!--  Name Label -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="center_horizontal">
        <android.support.design.widget.TextInputLayout
            android:layout_width="wrap_content"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp">
        <EditText android:id="@+id/register_first_name_edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textCapWords"
            android:hint="First Name" />
        </android.support.design.widget.TextInputLayout>
        <android.support.design.widget.TextInputLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp">
        <EditText android:id="@+id/register_last_name_edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textCapWords"
            android:hint="Last Name" />
        </android.support.design.widget.TextInputLayout>
    </LinearLayout>

    <!-- Email Label -->
    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp">
        <EditText android:id="@+id/register_email_edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textEmailAddress"
            android:hint="Email" />
    </android.support.design.widget.TextInputLayout>

    <!-- Password Label -->
    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp">
        <EditText android:id="@+id/register_password_edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPassword"
            android:hint="Password"/>
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp">
        <EditText android:id="@+id/register_confirm_password_edit_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPassword"
            android:hint="Confirm Password"/>
    </android.support.design.widget.TextInputLayout>

    <!-- Signup Button -->
    <android.support.v7.widget.AppCompatButton
        android:id="@+id/register_signup_button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="24dp"
        android:layout_marginBottom="24dp"
        android:padding="12dp"
        android:textSize="16sp"
        android:background="@color/colorPrimaryDark"
        android:text="Create Account"/>
</LinearLayout>
这里,InputLayout是与特定EditText字段关联的布局。最后,为了显示可拉伸的-

    myInputLayout.setErrorEnabled(false);                    
    myEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, mCorrectDrawable, null);
编辑2-以下是页面的外观-
注意我还对代码进行了编辑,以便只有相关代码可见。很抱歉编辑不好。

这里涉及的内容很多。有没有可能做得更多?你能分享一个真正的克林贡战士不评论他的代码吗。Qapla'
    myEditText.setCompoundDrawablesWithIntrinsicBounds(0,0,0,0);    //Remove all drawables from the edittext field
    myInputLayout.setErrorEnabled(true);
    myInputLayout.setError("Passwords do not match");
    myInputLayout.setErrorEnabled(false);                    
    myEditText.setCompoundDrawablesWithIntrinsicBounds(null, null, mCorrectDrawable, null);