在做登陆时用到的有关输入的密码显示与隐藏的代码,虽然很简单,但有用的东西,直接当笔记写下来,吼吼,先看下效果:
[img]
[img]http://dl.iteye.com/upload/attachment/0066/6889/28e8a0a4-4bc9-319d-ab8d-d3f29e62ef1c.jpg[/img]
[/img]
[img]
[img]http://dl.iteye.com/upload/attachment/0066/6891/8c2ed75f-9afc-34bb-9b1f-79ebf61c177c.jpg[/img]
[/img]
[img]
[img]http://dl.iteye.com/upload/attachment/0066/6893/8c0c9d32-0e5c-3072-a8e2-619a0fdda2d9.jpg[/img]
[/img]
下面来看下这代码有多简单,有用,小x就记下,不管多简单:
[img]
[img]http://dl.iteye.com/upload/attachment/0066/6889/28e8a0a4-4bc9-319d-ab8d-d3f29e62ef1c.jpg[/img]
[/img]
[img]
[img]http://dl.iteye.com/upload/attachment/0066/6891/8c2ed75f-9afc-34bb-9b1f-79ebf61c177c.jpg[/img]
[/img]
[img]
[img]http://dl.iteye.com/upload/attachment/0066/6893/8c0c9d32-0e5c-3072-a8e2-619a0fdda2d9.jpg[/img]
[/img]
下面来看下这代码有多简单,有用,小x就记下,不管多简单:
package com.xiaoma.www;
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;
/**
* @Title: PasswordIsShowTestActivity.java
* @Package com.xiaoma.www
* @Description: 用户登陆时密码操作
* @author MZH
* @version V2.2
*/
public class PasswordIsShowTestActivity extends Activity {
private EditText username;
private EditText password;
private CheckBox cbBox ;
/** Called when the activity is first created. */
@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()){
//HideReturnsTransformationMethod这个类朋友可以Ctrl跟踪下哦,吼吼
password.setTransformationMethod(
HideReturnsTransformationMethod.getInstance());
}else{
//下面这个类朋友们也可以自己跟下,很简单的
password.setTransformationMethod(
PasswordTransformationMethod.getInstance());
}
}
});
}
}