1

enter image description here

how to do click on drawableRight edit image of every TextInputEditText? I want to click on the edit icon and then enable to edit each field. How can i do this?

 <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <!--First name-->

            <com.google.android.material.textfield.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="@dimen/_64dp">

                <com.google.android.material.textfield.TextInputEditText
                   
                    android:id="@+id/etFirstName"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:focusableInTouchMode="true"
                    android:drawableRight="@drawable/icon_edit"
                    android:hint="@string/label_fname"
                    android:inputType="textCapWords" />
            </com.google.android.material.textfield.TextInputLayout>

            <!--Middle name-->
            <com.google.android.material.textfield.TextInputLayout
                android:id="@+id/activity_registration_tiMiddleName"
                android:layout_width="match_parent"
                android:layout_height="@dimen/_64dp">

                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/etMiddleName"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:focusableInTouchMode="true"
                    android:drawableRight="@drawable/icon_edit"
                    android:hint="@string/label_mname"
                    android:inputType="textCapWords"/>

            </com.google.android.material.textfield.TextInputLayout>


     </LinearLayout>

so how to each field individually edit using drawbleRight. Please help.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
TB13
  • 367
  • 13
  • 23

1 Answers1

8

Don't use android:drawableRight in the TextInputEditText.
Use:

<com.google.android.material.textfield.TextInputLayout
    ...
    app:endIconMode="custom"
    app:endIconDrawable="@drawable/..."

and:

textInputLayout.setEndIconOnClickListener {
  // Respond to end icon presses
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • 1
    This is perfect solution. Thanks a lot @ Mr. Gabrele Mariotti – TB13 Jun 29 '20 at 07:22
  • @ Gabriele Mariotti can you help me https://stackoverflow.com/questions/62789319/how-to-change-visiblity-visible-invisible-or-gone-of-setendicondrawable-in-t in this problem as it is related to this answer you helped me. – TB13 Jul 08 '20 at 13:09