Android Question Disable copy/paste?

bjf

Member
Licensed User
Longtime User
Hello.
Is there any way to disable the posibility for a user to copy the content of a specific Edittext?
 

mangojack

Well-Known Member
Licensed User
Longtime User
B4X:
EditText1.Enabled = False
or use a label ..

Why an EditText ? where user inputs text that you wish user not to copy?
 
Last edited:
Upvote 0

bjf

Member
Licensed User
Longtime User
It's like this:

The user uses the app to perform changeout of devices.

In addition to scan the devices barcode you can also register it manually by
typing the serial number.
But if you do, you are required to type it in twice, to make sure you got it right.

When the user moves to the confirmation edittext, the first one is set to visible=false in order for the user to actually read the number on the devuce again and not just write the same thing as in the first text.

But knowing peope, you always look for a shortcut and that's where the copy function comes in...
I bet they will start copying the contents of the first edittext before moving to the next and then paste it there.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
I bet they will start copying the contents of the first edittext before moving to the next and then paste it there.

fully agree .. just like me when asked to input email address twice when registering for various sites ...:rolleyes:
 
Upvote 0

bjf

Member
Licensed User
Longtime User
Last edited:
Upvote 0

James Chamblin

Active Member
Licensed User
Longtime User
Best idea I can come up with is to test how many characters are being entered at a time, and if more than one, reject the input.
B4X:
#Region  Project Attributes 
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName: 
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim ET As EditText
    Dim ET2 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    ET.Initialize("ET")
    Activity.AddView(ET,0,90dip,320dip,80dip)
    ET2.Initialize("")
    ET2.Text = "Do not copy this line"
    Activity.AddView(ET2,0,0,320dip,80dip)

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub ET_TextChanged (Old As String, New As String)
    If New.Length > Old.Length + 1 Then
        Msgbox("Please do not use copy/paste","Copy/Paste detected")
        ET.Text = ""
    End If
End Sub
 
Upvote 0
Top