59、常规控件(2)TextInputLayout-让EditText提示更加人性化

提示语用在显示。
<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提示更加人性化的更多相关文章
- Android AutoCompleteTextView控件实现类似百度搜索提示,限制输入数字长度
Android AutoCompleteTextView 控件实现类似被搜索提示,效果如下 1.首先贴出布局代码 activity_main.xml: <?xml version="1 ...
- WPF 控件被禁用,悬浮提示不显示问题
原文:WPF 控件被禁用,悬浮提示不显示问题 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/BYH371256/article/details/89 ...
- 61、常规控件(4)TabLayout-便捷实现标签
<android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width=&q ...
- 在WPF的WebBrowser控件中屏蔽脚本错误的提示
在WPF中使用WebBrowser控件显示网页时,经常会报脚本错误的提示,如何屏蔽掉这些错误提示呢.方法是定义如下方法: public void SuppressScriptErrors(WebBro ...
- ValidationSummary控件不弹出错误提示框
采用VS2013 编写的前台,运用ValidationSummary控件时,不出现错误弹窗,网上找到了解决方法 发现是ASP.NET 4.5对验证控件的影响(兼容性),使用ASP.NET 4.5的解决 ...
- VC/MFC 在ListCtl 控件中随鼠标移动提示单元格信息
BEGIN_MESSAGE_MAP(CTipListCtrl, CListCtrl) //{{AFX_MSG_MAP(CTipListCtrl) ON_WM_MOUSEMOVE() ON_WM_DES ...
- ATL控件签名之后页面还提示“在此页面上的Activex控件和本页上的其他部分及交互可能不安全”
ATL控件正常签名打包,然后安装之后还是会提示: 没理由啊,签名是花钱搞得正当的签名.后来查了资料才知道这还不够,需要在创建ATL控件的时候继承一个IObjectSafetyImpl 类 知道了原因, ...
- QT常规控件操作备忘
QLabel设置边框和颜色: label->setFrameShape (QFrame::Box); label->setStyleSheet("border: 1px soli ...
- html学习第一讲(内容html常规控件的的使用)
<html> <head> <title> 这是网页的标题</title> </head> <body> <h2>& ...
随机推荐
- Struts2的国际化入门
Struts2的国际化入门 Struts2国际化是建立在Java国际化的基础上的,一样是通过提供不同国家/语言环境的消息资源,然后通过ResourceBundle加载指定Locale对应的资源文件,再 ...
- SugarCE问题点记录
问:如何获取module参数?如果module参数不存在,如何处理?答:首先检查$_REQUEST['module'],然后再检查$sugar_config['default_module']是否有设 ...
- VMware Workstation Pro v14.0下载及永久激活密钥
VMware Workstation Pro v14.0 更新日志: 1.新版支持在Windows 10 创意者更新版上运行并且支持创建和运行创意者更新版虚拟机: 2.新版新增对Ubuntu 17.0 ...
- wps标准格式
- CentOS7关闭默认防火墙启用iptables防火墙
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤. 1.关闭firewall: systemctl stop firewalld.service #停止f ...
- Swashbuckle一个webapi调试利器
开发weibapi通常会使用postman或者其他模拟http请求的工具去模拟请求.但是这些工具需要自己保存请求地址的url以及参数 每次我都是先查询wiki看参数. 看见同事再用Swashbuckl ...
- VS创建、安装、调试 windows服务(windows service)
1.创建 windows服务 项目 文件 -> 新建项目 -> 已安装的模板 -> Visual C# -> windows ,在右侧窗口选择"windows 服 ...
- c#删除 list中的元素和怎么去除空元素
; i >= ; i--) { if (list[i].NO == item.NO) { list.RemoveAt(i); } } public void RemoveItemFromList ...
- NGUI 取ScrollView中遮罩区域4个点
用panel.localCorners而不是panel.finalClipRegion,Region还要再换算 首先通过ScrollView取panel,然后取Corners,它返回值代表4个点,映射 ...
- atitit.验证码识别step4--------图形二值化 灰度化
atitit.验证码识别step4--------图形二值化 灰度化 1. 常见二值化的方法原理总结 1 1.1. 方法一:该方法非常简单,对RGB彩色图像灰度化以后,扫描图像的每个像素值,值小于12 ...