4

enter image description here

as you can see from the image above, there is something like a toast with text "Frequently used email" . whenever I complete typing an email then that toast will appear, I don't think I make it programmatically. It seems it appears only on Android 10, in my Android Lollipop that toast doesn't appear. I use Xiaomi Redmi Note 7 for my Android 10.

I want to remove that toast from my edittext. how to do that ?

here is the XML for the edittext

<com.google.android.material.textfield.TextInputLayout
            android:id="@+id/email_login_textInputLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="32dp"
            android:layout_marginEnd="16dp"
            android:theme="@style/TextInputLayoutAppearance"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/imageView_back_button">


        <com.google.android.material.textfield.TextInputEditText
                android:id="@+id/email_textView_login"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:ems="10"
                android:hint="@string/email"
                android:inputType="textEmailAddress" />

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

and in Kotlin code, I just have this listener

        emailTextView.setOnFocusChangeListener { v, hasFocus ->

            val emailText = emailTextView.text.toString()

            if (!emailText.isEmpty()) {

                if (!hasFocus && (!emailText.contains("@") || (!emailText.contains(".")))) {
                    emailTextInputLayout.isErrorEnabled = true
                    emailTextInputLayout.error = "wrong email format"
                } else if (!hasFocus) {
                    emailTextInputLayout.isErrorEnabled = false
                    emailTextInputLayout.error = ""
                }

            }


        }

I have tried to change/remove android:inputType="textEmailAddress" , but that toast is still appear

sarah
  • 3,819
  • 4
  • 38
  • 80

1 Answers1

0

I was also facing this problem and have solved by adding the following -

  android:inputType="textNoSuggestions|textEmailAddress"

textNoSuggestions will prevent the 'frequently used email' toast and since the EditText is for email address so you need to add textEmailAddress as well

MrinmoyMk
  • 551
  • 7
  • 21