yourButton.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch ( event.getAction() ) { case MotionEvent.ACTION_DOWN: editText.setInputType(InputType.TYPE_CLASS_TEXT); break; case MotionEvent.ACTION_UP: editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); break; } return true; } });