Android EditText聚焦时hint消失的简单代码

 

        mInfo = (EditText) findViewById(R.id.fabu_info);

        mInfo.setOnFocusChangeListener(new OnFocusChangeListener() {

            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("");

                }

            }

        });

posted on 2012-12-21 19:05  zhengbeibei  阅读(326)  评论(0编辑  收藏  举报