本文共 1285 字,大约阅读时间需要 4 分钟。
- import android.app.Activity;
- import android.graphics.Rect;
- import android.os.Bundle;
- import android.text.method.HideReturnsTransformationMethod;
- import android.text.method.PasswordTransformationMethod;
- import android.text.method.TransformationMethod;
- import android.view.View;
- import android.widget.CheckBox;
- import android.widget.CompoundButton;
- import android.widget.CompoundButton.OnCheckedChangeListener;
- import android.widget.EditText;
-
-
- public class PasswordIsShowTestActivity extends Activity {
-
- private EditText username;
- private EditText password;
- private CheckBox cbBox ;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
-
- username = (EditText)findViewById(R.id.editText1);
- password = (EditText)findViewById(R.id.editText2);
- cbBox = (CheckBox)findViewById(R.id.checkBox1);
- cbBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
-
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if(cbBox.isChecked()){
- password.setTransformationMethod(
- HideReturnsTransformationMethod.getInstance());
- }else{
- password.setTransformationMethod(
- PasswordTransformationMethod.getInstance());
- }
- }
- });
- }
- }
转载于:https://www.cnblogs.com/zhiqiangsimida/archive/2012/04/17/2774701.html