Professional Documents
Culture Documents
Passwords have become lengthy and complicated for security purposes. At times, it becomes difficult to keep
track of typing the characters. To facilitate the user with the display of actual characters of password when
needed is a useful functionality. Many web logins and android applications are embedding this functionality for
user convenience.
In this Android Tutorial, we shall demonstrate on how to show/hide password in Android EditText with the help of
an example Application.
Create an Android Project and replace the activity_main.xml and MainActivity.kt with the following code.
activity_main.xml
</LinearLayout>
MainActivity.kt
package com.tutorialkart.showhidepassword
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
showHideBtn.setOnClickListener {
if(showHideBtn.text.toString().equals("Show")){
pwd.transformationMethod = HideReturnsTransformationMethod.getInstance()
showHideBtn.text = "Hide"
} else{
pwd.transformationMethod = PasswordTransformationMethod.getInstance()
showHideBtn.text = "Show"
}
}
}
}
⊩ Kotlin vs Java
Android TextView
⊩ Android TextView
Android Button
Android Toast
Android EditText
Android ImageView
Android SeekBar
Android Intent
Android AlertDialog
Android W ebView
Android ProgressBar
Android Snackbar
Android Canvas
⊩ Android runOnUiThread
Fix Errors
⊩ Android - All support libraries must use the exact same version specification
Example Applications
Kotlin - Java
⊩ Kotlin Tutorial
Useful Resources