提示语用在显示。

 <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) {}
});

最新文章

  1. ssh免密码认证
  2. [BZOJ2788][Poi2012]Festival
  3. ZOJ 1122 Clock(模拟)
  4. 如何设计一个更好的C++ ORM
  5. Ping命令详解
  6. UIWebViewでローカルにあるHTMLを表示する&amp;iOS6からtextAlignmentで指定する値が変更になった
  7. 导出Ext.grid.Panel到excel
  8. 论公司spring的滥用
  9. BZOJ 2276 Temperature
  10. java 文件操作 写入和读取(小结一)
  11. python模块(os,sys,hashlib,collections)
  12. P1494 [国家集训队]小Z的袜子
  13. Leaflet获取可视范围内4个顶点
  14. python中的Matplot库和Gdal库绘制富士山三维地形图-参考了虾神的喜马拉雅山
  15. git hub命令,上传到github
  16. 《Head First 设计模式》例子的C++实现(2 观察者模式)
  17. STL学习笔记--排序算法
  18. 字符串加u的特殊需求
  19. Java 对象初始化生命周期
  20. C# 二维码生成——QRCode

热门文章

  1. PHP-客户端的IP地址伪造、CDN、反向代理、获取的那些事儿
  2. CSS3使用Animation steps属性实现指针时钟效果
  3. jetty maven插件端口设置
  4. spring中添加redis缓存
  5. 使用typescript开发js代码提升代码维护性
  6. C# Oracle.ManagedDataAccess 批量更新表数据
  7. ((void *) 0)的含义和void的一些细节
  8. excel批量加前后缀
  9. MySQL主从同步那点事儿
  10. poj 1475 Pushing Boxes 推箱子(双bfs)