TQC-110 EditText的顯示密碼
這是TQC的110題,
程式碼為自行撰寫,
僅供參考。
主要練習EditText的顯示密碼,
很長很難記~~
HideReturnsTransformationMethod
PasswordTransformationMethod
package COM.TQC.GDD01;
import android.app.Activity;
import android.os.Bundle;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.EditText;
public class GDD01 extends Activity {
private CheckBox chk_show;
private EditText et_password;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findview();
setlistener();
}
public void findview()
{
chk_show=(CheckBox)findViewById(R.id.mCheck);
et_password=(EditText)findViewById(R.id.mPassword);
}
public void setlistener()
{
et_password.setTransformationMethod(PasswordTransformationMethod.getInstance());
chk_show.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(chk_show.isChecked()==true)
{
et_password.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
}
else
{
et_password.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
}});
}
}
自我LV~