Based on post #14 in this thread I created a simple application, just to show a long scrollable text.
Now I need to find a word within the text and position the view on that word.
Could anyone help?
The hole "project" is below and the long text (not that long, just to help...) is attached:
Now I need to find a word within the text and position the view on that word.
Could anyone help?
The hole "project" is below and the long text (not that long, just to help...) is attached:
B4X:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private scvText As ScrollView
Private lblText As Label
' Dim Times, Lucinda As Typeface
Dim obj1 As Reflector
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("longtext")
lblText.Initialize("lblText")
lblText.Color=Colors.RGB(255,255,161)
lblText.TextColor=Colors.Black
' Times=Typeface.LoadFromAssets("times.ttf")
' Lucinda=Typeface.LoadFromAssets("LHANDW.ttf")
' lblText.Typeface=Lucinda
obj1.Target = scvText ' a ScrollView
Dim args(3) As Object
args(0) = lblText
args(1) = -1
args(2) = -2
Dim types(3) As String
types(0) = "android.view.View"
types(1) = "java.lang.int"
types(2) = "java.lang.int"
obj1.RunMethod("removeAllViews")
obj1.RunMethod4("addView", args, types)
lblText.Text=File.GetText(File.DirAssets,"longtext.txt")
' search text?
Dim position As Int = 0 ' = search text...
scvText.ScrollPosition = position
End Sub