去掉hint提示文字
想要去掉EditText的hint提示文字,首先需要给EditText的父控件加上如下两个属性,使其获得焦点:
android:focusable="true"
android:focusableInTouchMode="true" et_comments.setOnFocusChangeListener(new OnFocusChangeListener() {
然后在代码中加入:
@Override public void onFocusChange(View v, boolean hasFocus) { // TODO Auto-generated method stub String hint; if (hasFocus) { hint = et_comments.getHint().toString(); et_comments.setTag(hint); et_comments.setHint(""); } else { hint = et_comments.getTag().toString(); et_comments.setHint(hint); } } });