android hint 自动消失
来源:互联网 发布:matlab遍历二维数组 编辑:程序博客网 时间:2024/06/10 22:09
android EditText有个hint属性,可以在用户没有选择输入框时给予提示
但是这个提示必须是在用户有输入字符后才会消失,似乎不太符合国人习惯,有时还会误导,所以要让用户点击到输入框时hint文本就自动消失,方法是监听焦点事件:
写一个公用的方法:
public static OnFocusChangeListener onFocusAutoClearHintListener = new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
EditText textView = (EditText) v;
String hint;
if (hasFocus) {
hint = textView.getHint().toString();
textView.setTag(hint);
textView.setHint("");
} else {
hint = textView.getTag().toString();
textView.setHint(hint);
}
}
};
给输入框绑定事件:
EditText loginNameTxt = (EditText) findViewById(R.id.loginNameTxt);
loginNameTxt.setOnFocusChangeListener(PublicFunc.onFocusAutoClearHintListener);
0 1
- android hint 自动消失
- android hint 自动消失
- android hint 自动消失
- android hint 自动消失
- android hint 自动消失 .
- Android EditText聚焦时hint消失的简单代码
- Android EditText聚焦时hint消失的简单代码
- Android EditText聚焦时hint消失的简单代码
- Android EditText聚焦时hint消失的简单代码
- EditText中hint消失
- Android中ProgressDialog自动消失
- Android禁止dialog自动消失
- android 点击Edittext时hint值不自动隐藏问题
- android中的对话框(AlertDialog)自动消失
- Android对话框显示后自动消失
- android memleak hint
- 王立平--android:hint
- android:点击popupwindow以外区域 popupwindow自动消失(转载)
- 中水处理设备分类方法及工艺流程选择
- 马航 挺住 全世界为你接机
- MapReduce中使用BytesWritable类型时要注意
- 2.7. About Secondary Storage
- MySQL 排序检索数据Select——MySQL系列(二)
- android hint 自动消失
- Android ListView 滑动分页
- struts2教程
- IOS怎样使用MessageUI Framework 发送短信息
- UIButton 多个事件 响应同一函数
- 2.8. About Physical Networks
- 用心情去游览
- Ssh连接linux 提示总线错误
- 配置Oracle Client 登陆管理远程数据库