Sub Globals
'These global variables will be redeclared each time the activity is created.
Private Edt As EditText
Private tmr As Timer
Private lblinfo As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
tmr.Initialize("tmr",1000)
tmr.Enabled=True
End Sub
Sub tmr_Tick
If IsCursorAtEnd(Edt) Then
lblinfo.Text="At end"
Else
lblinfo.Text="Not at end"
End If
End Sub
Sub Activity_Resume
End Sub
Sub IsCursorAtEnd(et As EditText) As Boolean
Dim jo As JavaObject = et
Dim cursorPosition As Int = jo.RunMethod("getSelectionStart", Null) ' Get current cursor position
' Convert the EditText text into a JavaObject and get the actual character length
Dim charSequence As JavaObject = jo.RunMethod("getText", Null)
Dim textLength As Int = charSequence.RunMethod("length", Null) ' Get length considering high Unicode characters
Return cursorPosition = textLength ' Compare cursor position with actual length
End Sub