android开发中EditText自动获取焦点时隐藏hint的代码
生活随笔
收集整理的這篇文章主要介紹了
android开发中EditText自动获取焦点时隐藏hint的代码
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
只需讓EditText設置以下的OnFocusChangeListener就可以了
private OnFocusChangeListener mOnFocusChangeListener = 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默認就會自動獲取焦點。解決之道:找一個EditText的父級控件,設置成 android:focusable="true" ? android:focusableInTouchMode="true"轉載于:https://www.cnblogs.com/huoshenmanbu/p/4902796.html
總結
以上是生活随笔為你收集整理的android开发中EditText自动获取焦点时隐藏hint的代码的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 动态追踪技术漫谈
- 下一篇: 猜数字游戏的提示(UVa340)