提示语用在显示。

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="@+id/textInput"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>

</LinearLayout>
TextInputLayout textInput = (TextInputLayout) this.findViewById(R.id.textInput);
textInput.setHint("请输入用户名");

         final TextInputLayout textInput = (TextInputLayout) this.findViewById(R.id.textInput);
textInput.setHint("请输入用户名"); EditText editText = textInput.getEditText();
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > 10) {
textInput.setError("用户名不能超过10位");
textInput.setErrorEnabled(true);
} else {
textInput.setErrorEnabled(false);
}
}
@Override
public void afterTextChanged(Editable s) {}
});

59、常规控件(2)TextInputLayout-让EditText提示更加人性化的更多相关文章

  1. Android AutoCompleteTextView控件实现类似百度搜索提示,限制输入数字长度

    Android AutoCompleteTextView 控件实现类似被搜索提示,效果如下 1.首先贴出布局代码 activity_main.xml: <?xml version="1 ...

  2. WPF 控件被禁用,悬浮提示不显示问题

    原文:WPF 控件被禁用,悬浮提示不显示问题 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/BYH371256/article/details/89 ...

  3. 61、常规控件(4)TabLayout-便捷实现标签

    <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width=&q ...

  4. 在WPF的WebBrowser控件中屏蔽脚本错误的提示

    在WPF中使用WebBrowser控件显示网页时,经常会报脚本错误的提示,如何屏蔽掉这些错误提示呢.方法是定义如下方法: public void SuppressScriptErrors(WebBro ...

  5. ValidationSummary控件不弹出错误提示框

    采用VS2013 编写的前台,运用ValidationSummary控件时,不出现错误弹窗,网上找到了解决方法 发现是ASP.NET 4.5对验证控件的影响(兼容性),使用ASP.NET 4.5的解决 ...

  6. VC/MFC 在ListCtl 控件中随鼠标移动提示单元格信息

    BEGIN_MESSAGE_MAP(CTipListCtrl, CListCtrl) //{{AFX_MSG_MAP(CTipListCtrl) ON_WM_MOUSEMOVE() ON_WM_DES ...

  7. ATL控件签名之后页面还提示“在此页面上的Activex控件和本页上的其他部分及交互可能不安全”

    ATL控件正常签名打包,然后安装之后还是会提示: 没理由啊,签名是花钱搞得正当的签名.后来查了资料才知道这还不够,需要在创建ATL控件的时候继承一个IObjectSafetyImpl 类 知道了原因, ...

  8. QT常规控件操作备忘

    QLabel设置边框和颜色: label->setFrameShape (QFrame::Box); label->setStyleSheet("border: 1px soli ...

  9. html学习第一讲(内容html常规控件的的使用)

    <html> <head> <title> 这是网页的标题</title> </head> <body> <h2>& ...

随机推荐

  1. struts2 常用标签

    版权声明:本文为博主原创文章,未经博主允许不得转载. Struts2可以将所有标签分成3类: 准备工作:需要在JSP页面引入标签库 <%@ taglib prefix="s" ...

  2. Linux命令-网络命令:setup

    setup 进入设置网络信息的界面 上图中选“网络配置”进入设置网络信息 上图中选“设备配置”进行配置IP地址,下图显示网卡信息 上图中,选择“eth0”回车进入设置eth0网卡信息界面 上图中选择“ ...

  3. 【转载】XGBoost调参

    General Parameters: Guide the overall functioning Booster Parameters: Guide the individual booster ( ...

  4. xgboost 自定义目标函数和评估函数

    https://zhpmatrix.github.io/2017/06/29/custom-xgboost/ https://www.cnblogs.com/silence-gtx/p/5812012 ...

  5. Lintcode---二叉树的层次遍历(原型)

    给出一棵二叉树,返回其节点值的层次遍历(逐层从左往右访问) 您在真实的面试中是否遇到过这个题? Yes 样例 给一棵二叉树 {3,9,20,#,#,15,7} : 3 / \ 9 20 / \ 15 ...

  6. Sql添加测试数据

    --建测试表 CREATE TABLE T_UserInfo ( Userid varchar(20),  UserName varchar(20), RegTime datetime, Tel va ...

  7. unity, 什么时候用静态类,什么时候用单例

    如果没有成员变量,或者成员变量都是常量,则用静态类. 如果有成员变量,则用单例.(以便让成员变量有初始化机会). //静态类 public class CmyFuncs{ public float m ...

  8. vue2项目 :在hosts里面配置了装逼的模式。设置应用在127.0.0.1:80端口访问; 并将127.0.0.1指向www.yours.com ;问题“ Invalid Host header”

    转自博客:https://www.cnblogs.com/cynthia-wuqian/p/8575401.html 1.MAC设置应用在127.0.0.1:80端口访问: config/index. ...

  9. matplotlib之极坐标系的极角网格线(thetagrids)的显示刻度

    极坐标系的极角网格线(thetagrids)的显示刻度 #!/usr/bin/env python3 #-*- coding:utf-8 -*- ########################### ...

  10. apache ab测试

    网站并发测试,网站服务使用的是apache2.4 因此使用ab来测试网站性能. windows使用cms 打开apache/bin 运行ab.exe (......../apache/bin/ab), ...