Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim scvText As ScrollView
Dim lblText As Label
Dim txt As String
Dim StrUtil As StringUtils
Dim pm As PackageManager
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")
scvText.Initialize(100) ' initialize the Scrollview
Activity.AddView(scvText, 0, 0, 100%x, 100%y) ' add the Scrollview on the Activity
Activity.Title = "Ver. "&pm.GetVersionName(Main.appname)&" B"&pm.GetVersionCode(Main.appname)
lblText.Initialize("") ' initialize the Label for the text, without an EventName
scvText.Panel.AddView(lblText, 0, 0 ,100%x, 100%y) ' add the Label on the ScrollView internal Panel
Activity.Color = Colors.RGB(250, 250, 210) ' set the Label background color
lblText.Color = Colors.RGB(250, 250, 210) ' set the Label background color
lblText.TextColor = Colors.Black ' set the Label text color
LoadText ' load the text
SetText ' set the text
End Sub
Sub LoadText
'Dim tr As TextReader
'tr.Initialize2(File.OpenInput(File.DirAssets, "version_history.txt"), "utf-8")
'Dim s As String
'txt = tr.ReadAll
txt = File.GetText(File.DirAssets, "version_history.txt") ' load the text file into the string
End Sub
Sub SetText
Dim ht As Float
lblText.Text = txt ' set the text string to the Label text property
ht = StrUtil.MeasureMultilineTextHeight(lblText, txt) ' measure Label height
scvText.Panel.Height = ht ' set the ScrollView internal Panel height to the measured height
lblText.Height = ht ' set the Label height to the measured height
scvText.ScrollPosition = 0 ' set the scroll position to the top of the text
DoEvents ' needed to execute the previous line
End Sub