B4J Code Snippet Wrap tooltip text

SubName: TooltipWrap

Description: Wrapping text in a tooltip


B4X:
Public Sub TooltipWrap(N As JavaObject,Width As Double)
    Try
        Dim Tooltip As JavaObject = N.RunMethod("getTooltip",Null)
        Tooltip.RunMethod("setPrefWidth",Array(Width))
        Tooltip.RunMethod("setWrapText",Array(True))
    Catch
        Log(LastException)
    End Try
End Sub

Dependencies: JavaObject

Tags: B4j Wrap Text Tooltip
 

stevel05

Expert
Licensed User
Longtime User
N is the view that the tool tip is attached to.
 

Ilya G.

Active Member
Licensed User
Longtime User
I try use

B4X:
Dim N As JavaObject = label1
Dim Tooltip As JavaObject = N.RunMethod("getTooltip", Null)
Tooltip.RunMethod("setPrefWidth", Array(300))
Tooltip.RunMethod("setWrapText", Array(True))

But get error

B4X:
java.lang.RuntimeException: Method: setPrefWidth not matched.
 

stevel05

Expert
Licensed User
Longtime User
I think the value passed to prefwidth should be a double, you are currently passing an int.

Try
B4X:
Tooltip.RunMethod("setPrefWidth", Array(300.0))
 
Top