How to disable copy paste in Edittext in Android

Ashu Maurya
1 min readFeb 24, 2021

I got this requirement from the client side; to avoid copy paste on password and confirm password edittext. So as usual I searched it on stackoverflow.com but none of them have worked even asked my seniors ..they also followed the same method.

I tried and tried and got the solution …in which u cannot disable the copy paste but you can change the effect of copy paste …

So here is the code …

First you have to make one interface file

File Name: MyEditTextListener.java

Then you have to make class which extend Edittext of Android X.

File Name: MyEditText.java

Suppose in login screen you have the password edittext. In the layout file you have to make changes there instead of simply edittext tag. Example below is implemented…

Made changes in layout file

Now Implement on respective activity or fragment.

Conclusion

Thank you for reading this tutorial. Let me know in the comments if this tutorial helped you.

Updated Post

Github Link : https://github.com/ashumau845/seminarintroduction

Go to the package: kotlin-activity/RegistrarionKotlinactivity.kt line no: 18

you can see it is implemented

--

--