Android输入框切换密码显示与隐藏

来源:互联网 发布:职场英语口语软件 编辑:程序博客网 时间:2024/05/14 09:52
         pwd = (EditText) findViewById(R.id.e1);  
       Button btn = (Button) findViewById(R.id.b1);  
       btn.setOnClickListener(new OnClickListener() {  
             
           @Override  
           public void onClick(View v) {  
              if(pwd.getInputType()==128){
              pwd.setInputType(129);
              }else{
              pwd.setInputType(128);
              }
              pwd.postInvalidate();  
              Spannable text=pwd.getText();
              Selection.setSelection(text, text.length());
           }  
       });    
0 0
原创粉丝点击