I am creating a slider in my code to a one of my TreeView Columns as it is being created.
and trying to use the code show here https://www.b4x.com/android/forum/threads/slider-show-value-in-thumb.72271/#content
B4X:
...
Dim TrackItem As TreeTableItem
Dim TrackLabel As Button = CreateButton("TrackNumber")
Dim MP3Slider As Slider = CreateSlider("MP3Slider")
TrackItem.Initialize("Track", Array As Object("", Column, MP3Slider, "", TrackLabel, FormatTime(TrackInfo.Duration), TrackInfo.Song, TrackInfo.TrackArtist, TrackInfo.FileName, ""))
...
Public Sub CreateSlider(InitAs As String) As Slider
Dim MakeSlider As Slider
MakeSlider.Initialize(InitAs)
' SliderTrackColorRGB(MakeSlider, 0, 0, 255) ' Either of these routines fail with JavaObject
' SliderBindLabel(MakeSlider, "%.0f")
Return MakeSlider
and trying to use the code show here https://www.b4x.com/android/forum/threads/slider-show-value-in-thumb.72271/#content
B4X:
Public Sub SliderTrackColorRGB(slr As Slider, r As Int, g As Int, b As Int)
Dim joSldr As JavaObject = slr
joSldr.RunMethodJo("lookup", Array(".track")).RunMethod("setStyle", Array($"-fx-background-color:rgb(${r},${g},${b});"$)) [B][U][I] ' This line fails[/I][/U][/B]
End Sub
Public Sub SliderBindLabel(sldr As Slider, fmt As String)
Dim SliderLabel As Label
SliderLabel.Initialize("SliderLabel")
Dim joSlider As JavaObject = sldr
Dim joLabel As JavaObject = SliderLabel
' Get the valueproperty of the slider as StringBinding
Dim vp As JavaObject = joSlider.RunMethodJO("valueProperty", Null).RunMethod("asString", Array(fmt)) [B][U][I] ' This line fails[/I][/U][/B]
' Bind the slider stringbinding to the label
joLabel.RunMethodjo("textProperty", Null).runmethodjo("bind", Array(vp))
' Add the label to the slider thumb
joSlider.RunMethodJo("lookup", Array(".thumb")).RunMethodJo("getChildren", Null).RunMethod("add", Array(SliderLabel))
End Sub
[/code
but the routines keep failing saying
java.lang.RuntimeException: Object should first be initialized (JavaObject).
If I DO NOT call those routines (calling just to make slider look nice) the slider in the TreeView Column is created just fine and works.