/** * Sets the transformation that is applied to the text that this * TextView is displaying. * * @attr ref android.R.styleable#TextView_password * @attr ref android.R.styleable#TextView_singleLine */ public final void setTransformationMethod (TransformationMethod method){ mInputView.setTransformationMethod(method); }
EditText edittext = (EditText)findViewById(R.id.passWordEditText); edittext.setTransformationMethod(new AsteriskPasswordTransformationMethod());
EditText editText = (EditText) findViewById(R.id.MyEditText); editText.setInputType(InputType.TYPE_CLASS_NUMBER); editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
EditText password = (EditText) findViewById(R.id.password_text); password.setTransformationMethod(new PasswordTransformationMethod());
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View result=inflater.inflate(R.layout.editor, container, false); editor=result.findViewById(R.id.editor); editor.setTransformationMethod(new DummyTransformationMethod()); return(result); }
EditText password = (EditText) findViewById(R.id.register_password_text); password.setTypeface(Typeface.DEFAULT); password.setTransformationMethod(new PasswordTransformationMethod());
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { int position=getArguments().getInt(KEY_POSITION, -1); View result; if (position==2) { ViewGroup doctorNo=new NoAssistFrameLayout(getActivity()); inflater.inflate(R.layout.editor, doctorNo); result=doctorNo; } else { result=inflater.inflate(R.layout.editor, container, false); } EditText editor=result.findViewById(R.id.editor); editor.setHint(getTitle(getActivity(), position)); if (position==1) { editor. setTransformationMethod(PasswordTransformationMethod. getInstance()); } return(result); } }
mEtPwd.setTransformationMethod(PasswordTransformationMethod.getInstance()); } else { mEtPwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
void passwordVisibilityToggleRequested() { if (passwordToggleEnabled) { // Store the current cursor position final int selection = editText.getSelectionEnd(); if (hasPasswordTransformation()) { editText.setTransformationMethod(null); passwordToggledVisible = true; } else { editText.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordToggledVisible = false; } passwordToggleView.setChecked(passwordToggledVisible); // And restore the cursor position editText.setSelection(selection); } }
/** * Returns whether the password visibility toggle functionality is enabled or not. * <p> * <p>When enabled, a button is placed at the end of the EditText which enables the user * to switch between the field's input being visibly disguised or not.</p> * * @param enabled true to enable the functionality * @attr ref android.support.design.R.styleable#TextInputLayout_passwordToggleEnabled */ public void setPasswordVisibilityToggleEnabled(final boolean enabled) { if (passwordToggleEnabled != enabled) { passwordToggleEnabled = enabled; if (!enabled && passwordToggledVisible && editText != null) { // If the toggle is no longer enabled, but we remove the PasswordTransformation // to make the password visible, add it back editText.setTransformationMethod(PasswordTransformationMethod.getInstance()); } // Reset the visibility tracking flag passwordToggledVisible = false; updatePasswordToggleView(); } }
@Override public void onCheckedChanged( final CompoundButton buttonView, final boolean isChecked ) { if ( isChecked ) { passEdit.setTransformationMethod(SingleLineTransformationMethod.getInstance()); } else { passEdit.setTransformationMethod(PasswordTransformationMethod.getInstance()); } } });
@Override public void hidePassword() { iv_hide.setVisibility(View.GONE); iv_show.setVisibility(View.VISIBLE); et_password .setTransformationMethod(HideReturnsTransformationMethod .getInstance()); }
@Override public void showPassword() { iv_show.setVisibility(View.GONE); iv_hide.setVisibility(View.VISIBLE); et_password .setTransformationMethod(PasswordTransformationMethod .getInstance()); }
@Override public void hidePassword() { iv_hide.setVisibility(View.GONE); iv_show.setVisibility(View.VISIBLE); et_password .setTransformationMethod(HideReturnsTransformationMethod .getInstance()); }
@Override public void onClick(View v) { if (show.getText().toString() == "SHOW") { edit_password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); show.setText("HIDE"); } else { edit_password.setTransformationMethod(PasswordTransformationMethod.getInstance()); show.setText("SHOW"); } } }
@Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { //切换明密文 if (checked) { mAccountLoginEtPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); } else { mAccountLoginEtPassword.setTransformationMethod(PasswordTransformationMethod.getInstance()); } //光标在末尾显示 mAccountLoginEtPassword.setSelection(mAccountLoginEtPassword.length()); } });
@Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { if (checked) { mEtPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); mEtRepassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); } else { mEtPassword.setTransformationMethod(PasswordTransformationMethod.getInstance()); mEtRepassword.setTransformationMethod(PasswordTransformationMethod.getInstance()); } mEtPassword.setSelection(mEtPassword.length()); mEtRepassword.setSelection(mEtRepassword.length()); } });
private void setInputAsPasswordDots() { setRevealIconColor(R.color.kinrecovery_gray); passwordField.setInputType(passInputType); passwordField.setTransformationMethod(LargePasswordDotsTransformationMethod.getInstance()); passwordField.setTypeface(Typeface.SANS_SERIF); passwordField.setSelection(passwordField.getText().length()); isRevealPressed = false; }
private void setInputAsVisibleChars() { setRevealIconColor(R.color.kinrecovery_bluePrimary); passwordField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_FILTER); passwordField.setTransformationMethod(null); passwordField.setTypeface(Typeface.SANS_SERIF); isRevealPressed = true; }
@Override public void onClick(View view) { if ((boolean) passwdView.getTag()) { passwdView.setTransformationMethod(new PasswordTransformationMethod()); } else passwdView.setTransformationMethod(new HideReturnsTransformationMethod()); passwdView.setTag(!(boolean) passwdView.getTag()); passwdView.setSelection(passwdView.getText().length()); } });