Scrollable text

stefanoa

Active Member
Licensed User
Longtime User
I need for automatic scrollable text from right to left, and when finished on the left, disappear and then restart from the right..
 
Upvote 0

stefanoa

Active Member
Licensed User
Longtime User
Yes thanks!

the code:
B4X:
....
DisplayText("This is a scrollable text")
....

Sub DisplayText(xtext as string)
  ScrollTitleLabel.Text=xtext
  SetEllipsize(ScrollTitleLabel, "MARQUEE")
end sub

Sub SetEllipsize(TextView As Label, Mode As String)
    Dim r As Reflector
    r.Target = TextView
    r.RunMethod2("setLines", 1, "java.lang.int")
    r.RunMethod2("setHorizontallyScrolling", True, "java.lang.boolean") 
    r.RunMethod2("setEllipsize", Mode, "android.text.TextUtils$TruncateAt")
    r.RunMethod2("setSelected", True, "java.lang.boolean")
End Sub
 
Upvote 0

jcesar

Active Member
Licensed User
Longtime User
Great code!

Works fine, but after some minutes the text scroll stop.

And in android 4.x sometimes dont begin to scroll as activity start.
 
Upvote 0

straybullet

Member
Licensed User
Longtime User
Ok what am I missing, I added a edittext to the designer called ScrollTitleLabel


And generated the member for it, and I run it on a Android phone I get a Java runtime exception of Object should first be initialized (EditText)

So what view do I need to add and what should I call it. I added the reflection library already.

Thanks

Yes thanks!

the code:
B4X:
....
DisplayText("This is a scrollable text")
....

Sub DisplayText(xtext as string)
  ScrollTitleLabel.Text=xtext
  SetEllipsize(ScrollTitleLabel, "MARQUEE")
end sub

Sub SetEllipsize(TextView As Label, Mode As String)
    Dim r As Reflector
    r.Target = TextView
    r.RunMethod2("setLines", 1, "java.lang.int")
    r.RunMethod2("setHorizontallyScrolling", True, "java.lang.boolean") 
    r.RunMethod2("setEllipsize", Mode, "android.text.TextUtils$TruncateAt")
    r.RunMethod2("setSelected", True, "java.lang.boolean")
End Sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Use a label instead of edittext. Call it:ScrollTitleLabel. Also I assume you use Reflection lib: 2.20. I just ran it on a Razr phone and it works.
 
Upvote 0
Top