Android : 编辑文本警报

Android : edittext alert

是否可以在编辑文本中创建警报?

我在 2 个应用程序中看到它的样式完全相同,所以我知道它是默认视图或 属性。

你必须使用 https://github.com/vekexasia/android-edittext-validator

您可以为测试属性设置多个值:

  1. 正则表达式:用于自定义正则表达式
  2. numeric: 对于唯一的数字字段
  3. alpha:仅用于 alpha 字段
  4. 字母数字:
  5. personName:检查输入的文本是人名还是姓氏。
  6. personFullName:检查输入的值是否是完整的全名。
  7. 电子邮件:检查该字段是否为有效电子邮件
  8. creditCard:使用 Luhn 算法检查该字段是否包含有效的信用卡
  9. phone:检查字段是否包含有效的 phone 数字
  10. domainName:检查字段是否包含有效域名(始终通过 API Level < 8 的测试)
  11. ipAddress:检查该字段是否包含有效的 ip 地址
  12. webUrl:检查该字段是否包含有效的 url(始终通过 API 级别 < 8 的测试)
  13. 日期:检查字段是否为有效的date/datetime格式(如果设置了 customFormat,则使用 customFormat 进行检查)
  14. nocheck:除了字段是否为空,它不检查任何内容。

可以使用setError方法。它仅在 API 一级可用。

editText.setError("Enter yor error message").
 <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp">

            <EditText
                android:id="@+id/phone"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="15dp"
                android:hint="@string/cont_num"
                android:inputType="phone"/>

        </android.support.design.widget.TextInputLayout>

来自 android 设计库

与其使用 EditText 小部件,一种解决方案是使用 RelativeLayout 和自动完成 TextView 小部件,并在 RL 中将您选择的警报图标设置在 AC TextView 的右侧。

然后向您的 AC textview 添加一个文本更改侦听器,它正在寻找您的特定文本输入,即二进制文件,如果检测到违规,则显示警告和错误图标?