具体代码如下:
final EditText et = (EditText)findViewById(R.id.tv);
CheckBox cBox = (CheckBox)findViewById(R.id.box);
cBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
et.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
}else {
et.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
}
}); final EditText e