標籤:android edittext
代碼已經整理好,效果如:
code:
//設定輸入為Cipher 模式 inputETP1.setInputType(InputType.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_VARIATION_PASSWORD); inputETP1.setDrawableRightListener(new EditTextPassword.DrawableRightListener() { @Override public void onDrawableRightClick() { //同樣地可以在這可以實現其他的效果,比如一鍵清空 if (mIsShow1) { inputETP1.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.eye_grey, 0); inputETP1.setInputType(InputType.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_VARIATION_PASSWORD); } else { inputETP1.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.eye_orange, 0);// inputETP.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); inputETP1.setInputType(InputType.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_VARIATION_NORMAL); } mIsShow1 = !mIsShow1; } });
650) this.width=650;" src="https://s3.51cto.com/wyfs02/M00/06/8B/wKiom1m59KeDzXOLAACbVGiWoZ4113.png" title="QQ20170914111544.png" alt="wKiom1m59KeDzXOLAACbVGiWoZ4113.png" />
地址:https://github.com/geeklx/MyApplication/tree/master/p039_edittextpwd
本文出自 “梁肖技術中心” 部落格,請務必保留此出處http://liangxiao.blog.51cto.com/3626612/1965175
Android Studio 第五十三期 - 自訂EditText密碼鍵盤