密码的显示隐藏
<CheckBox android:id="@+id/checkbox_login" android:layout_width="@dimen/dp_20" android:layout_height="@dimen/dp_10" android:layout_alignParentRight="true" android:layout_centerVertical="true" android:layout_marginRight="@dimen/dp_10" android:background="@drawable/cb_pwd_select" android:button="@null" />
/** * 登录密码用*还是显示数字 */ checkboxLogin.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { int num = etLoginPwd.getText().toString().trim().length(); if (isChecked) { //如果选中,显示密码 etLoginPwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); etLoginPwd.setSelection(num); } else { //否则隐藏密码 etLoginPwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); etLoginPwd.setSelection(num); } } });
上一篇: 拖动条SeekBar的使用