实现代码:
//光标处在EditText时其内容消失 mInfo = (EditText)findViewById(R.id.old_password); //setOnFocusChangeListener 焦点事件 mInfo.setOnFocusChangeListener(new View.OnFocusChangeListener() { //v 发生变化的视图 hasFocus:用来判断视图是否获得了焦点 public void onFocusChange(View v,boolean hasFocus) { EditText _v = (EditText)v; if(!hasFocus) { _v.setHint(_v.getTag().toString()); } else { String hint = _v.getHint().toString(); _v.setTag(hint); _v.setHint(""); } } });