如何在我的编辑文本中删除“常用电子邮件”吐司?

问题描述

enter image description here

从上图可以看到,有一个类似敬酒的文本“频繁使用的电子邮件”。每当我完成一封电子邮件的输入时,该吐司就会出现,我认为我不是以编程方式完成的。看来它仅出现在Android 10上,在我的Android Lollipop中却没有出现吐司。我在Android 10上使用小米Redmi Note 7。

我想从我的编辑文本中删除该吐司。该怎么做?

这是edittext的XML

<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>

在Kotlin代码中,我只有这个侦听器

        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 = ""
                }

            }


        }

我尝试更改/删除android:inputType="textEmailAddress",但仍然有吐司

解决方法

我也面临这个问题,并通过添加以下内容来解决-

  android:inputType="textNoSuggestions|textEmailAddress"

textNoSuggestions将阻止“频繁使用电子邮件”的举动,并且由于EditText用于电子邮件地址,因此您也需要添加textEmailAddress