Textview

omoba

Active Member
Licensed User
Longtime User
There is something strange with code below --got it from the forum


------------------------------------------------------------------
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim Label1 As Label
Dim Label2 As Label
Dim txt As String
Dim CCT As ClickableTV

End Sub
-----------------------------------------------
Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("ClickableTVLayout")
txt = File.GetText(File.DirAssets, "text.txt")
arrWord = Regex.Split(" ", txt)
For k = 0 To arrWord.Length - 1
CCT.AddLinkText(Label2,arrWord( k ).Trim ,Colors.White,"GetString")
Next

End Sub

--------------------------------------------------------------------------
Sub GetString_clickablelink (Text As String)

Label3.Text = Text

End Sub
--------------------------------------------------------------------------




With this code, the text is loaded to the label but not spaced out properly. If I add an extra space inside the quotation mark in code line
arrWord = Regex.Split(" ", txt)
the text is displayed properly but messes up the click

Without the extra space I can click on a word and that word only is displayed in Label1.

When I add extra space for proper display, instead of the word clicked being displayed in Label1, all the text loaded to Label2 would be displayed in Label1.

Pls how can I fix this? I want properly spaced out text in Label2 and have ability to click a word and display it in Label1.


Thanks
 

mc73

Well-Known Member
Licensed User
Longtime User
I'm trying really hard to understand. Regex.split will split your sentence (in your case, a whole file) into words. Appening all these words in the textView, will result into showing each time, one single word. I think you need to get the whole sentence. If that's the case, instead of using getText, you could use readList for example, then fit into the textView the line you desire. Again, if I understood correctly.
 
Upvote 0

omoba

Active Member
Licensed User
Longtime User
Fixed

I just added spaces to line of code below before displaying


CCT.AddLinkText(Label2,arrWord(k).Trim & " " & " ",Colors.black,"GetString")
 
Upvote 0
Top