Google Android SDK开发范例------------20141119

时间:2023-03-08 19:29:37

一、Edit和Checkbox完成对登陆密码的查看:添加Edit的setOnCheckedChageListener和对CheckBox的状态通过isCHecked判断

大体代码如下

CheckBox.setOnClickedChangeListener(

  new CheckBox.OnClickedChangeListener()
  {  

    public void onCheckedChanged(CompoundButton arg0, boolean arg1){
       if(checkbox.isChecked()){
          EditText.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
       }
       else{
          EditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
       }
    }

  }

);

同时在layout.xml文件中添加android:hint添加默认提示信息