public class ClickProjectActivity extends Activity {
private EditText input = null;
private CheckBox check = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
input = (EditText)this.findViewById(R.id.input);
check = (CheckBox)this.findViewById(R.id.check);
//CheckBox加上事件监听
check.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if(isChecked){
//设置成明文
//This transformation method causes any carriage return characters (\r)
//to be hidden by displaying them as zero-width non-breaking space characters ().
input.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
}else{
//设置成密文
//
input.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
}
});
}
}