光标移动到最后
etPassword.setSelection(etPassword.getText().length());
密码的显示与隐藏
if (isShowHidePassword) {
//显示密码
etPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
isShowHidePassword = false;
} else {
//隐藏密码
etPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
isShowHidePassword = true;
}
Android 如何使edittext默认失去焦点
1.在布局文件中给edittext的父控件增加两个属性
android:focusable="true"
android:focusableInTouchMode="true"
2.直接调用edittext的clearFocus()方法,不过该方法有时候会不生效
searchView.setFocusable(true); searchView.setFocusableInTouchMode(true); searchView.requestFocus();
searchView.clearFocus();//失去焦点
searchView.requestFocus();//获取焦点</pre>