Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
Dim tv As TableView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
tv.Initialize("tv")
tv.SetColumns(Array("one","two","three"))
tv.setColumnWidth(0,50)
tv.setColumnWidth(1,50)
tv.setColumnWidth(2,200)
For a = 0 To 20
Dim item(3) As Object
item(0) = a
item(1) = a * 2
item(2) = "item" & a
tv.Items.Add(item)
Next
MainForm.RootPane.AddNode(tv,20,50,300,300)
' highlight rows containing "item2"
(Me).As(JavaObject).RunMethod("setRowColour",Array(tv,"item2"))
End Sub
Sub Button1_Click
xui.MsgboxAsync("Hello World!", "B4X")
End Sub
#if java
import javafx.scene.control.*;
public static void setRowColour(TableView tabv, String keyValue){
tabv.setRowFactory(tv -> new TableRow<Object[]>() {
@Override
protected void updateItem(Object[] item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setStyle("");
} else if (((String)item[2]).contains(keyValue)) { // put your test here remember cols start at 0
// Change the color of the row based on the value in the column
setStyle("-fx-background-color: lightgreen;");
} else {
setStyle("");
}
}
});
}
#End If