Continuing Adding Text to a Scrollview Label

Lostmymind

Banned
Trying to get a scrollview to be have a label with text that is getting writting to to help with debuging my code. I have looked at the examples and got load in a text file with the scroll view to work but when I try to write to a label to add more text it does not show up.
 

yttrium

Active Member
Licensed User
Longtime User
Trying to get a scrollview to be have a label with text that is getting writting to to help with debuging my code. I have looked at the examples and got load in a text file with the scroll view to work but when I try to write to a label to add more text it does not show up.

You should add to a label like so:

B4X:
Dim Label1 As Label
Label1.Text = "firsttext"
Label1.Text = Label1.Text & CRLF & "secondtext"
 
Upvote 0

Lostmymind

Banned
Thanks yttrium

not sure what you mean in your code 'CRLF"

but i did get to work when I added this to my code.

Dim ht As Float

Activity.Title = "Current Tab = " & Host.CurrentTab

If Host.CurrentTab = 3 Then
DebugLabel.Text = DebugLabel.Text
ht=StrUtil.MeasureMultilineTextHeight (DebugLabel, DebugLabel.Text)+ 250
Debug_veiw.Panel.Height = ht
DebugLabel.Height = ht
Debug_veiw.ScrollPosition = 0
DoEvents
End If


thanks for the help.:)

Not sure if i would need to make a new thread for another question.
Is there a work around or a way to do a Vertical and a horizontal scroll view?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
... what you mean in your code 'CRLF'
CRLF is a B4A constant for carriage return.


In this line:
B4X:
ht=StrUtil.MeasureMultilineTextHeight (DebugLabel, DebugLabel.Text)+ 250
Why do you need 250 extra pixels ?
Even though you should use 250dip instead of 250.

Is there a work around or a way to do a Vertical and a horizontal scroll view?
Yes with ScrollView2D.

Best regards.
 
Upvote 0

yttrium

Active Member
Licensed User
Longtime User
Thanks yttrium

not sure what you mean in your code 'CRLF"

but i did get to work when I added this to my code.

Dim ht As Float

Activity.Title = "Current Tab = " & Host.CurrentTab

If Host.CurrentTab = 3 Then
DebugLabel.Text = DebugLabel.Text
ht=StrUtil.MeasureMultilineTextHeight (DebugLabel, DebugLabel.Text)+ 250
Debug_veiw.Panel.Height = ht
DebugLabel.Height = ht
Debug_veiw.ScrollPosition = 0
DoEvents
End If


thanks for the help.:)

Not sure if i would need to make a new thread for another question.
Is there a work around or a way to do a Vertical and a horizontal scroll view?

Oh, I'm sorry, I thought you were having trouble adding text to the label, not resizing the ScrollView to fit the new dimensions.

B4X:
DebugLabel.Text = DebugLabel.Text
Why do you need this line? It does absolutely nothing.
 
Upvote 0

Lostmymind

Banned
line code:
ht=StrUtil.MeasureMultilineTextHeight (DebugLabel, DebugLabel.Text)+ 250

the 250 extra pixels would not allow the final line of text to show. Without the extra pixels the last line or 2 will not show.

I did download the scrollView2D. I got it in my Lib files and loaded them in. but when I go to the Designer window and load in my layout that I will need the scrollview2d in there is no scrollview2d in the list to pick from.

did i miss a step?
 
Upvote 0

yttrium

Active Member
Licensed User
Longtime User
line code:
ht=StrUtil.MeasureMultilineTextHeight (DebugLabel, DebugLabel.Text)+ 250

the 250 extra pixels would not allow the final line of text to show. Without the extra pixels the last line or 2 will not show.

Be sure to use dip!
 
Upvote 0

Lostmymind

Banned
I did not notice I left the code: DebugLabel.Text = DebugLabel.Text
it was deleted and i did change the line:
ht=StrUtil.MeasureMultilineTextHeight (DebugLabel, DebugLabel.Text)+ 250
over to
ht=StrUtil.MeasureMultilineTextHeight (DebugLabel, DebugLabel.Text) & CRLF
it does show all text and when I add more it still shows all of the text.

Thanks for the tip

Now just need to get the Scrollview2D to work and learn how to setup.
 
Last edited:
Upvote 0
Top