Hi All,
I am trying to set/change the contents of an individual cell in a tableView.
I have followed the example from Erel, 'tableExample' and it works with 1 form and 1 tableView.
Log results..
In my app I use the same code except the tableView is on a form that is opened on top of the main form and I get an error. This form has 2 tableViews on it.
The code is for all intensive purposes the same except for the table and variable names but outputs totally different log values and the second version errors. I have tried everything I can think of to find the problem.
Any ideas.
Thanks
I am trying to set/change the contents of an individual cell in a tableView.
I have followed the example from Erel, 'tableExample' and it works with 1 form and 1 tableView.
B4X:
Sub btnUpdate_Action
If TableView1.SelectedRow = -1 Then Return
SetCellValue(TableView1.SelectedRow, 1, txtValue.Text)
End Sub
Sub SetCellValue(RowIndex As Int, CellIndex As Int, Value As String)
Log ("rowIndex= "&RowIndex&", CellIndex = "&CellIndex&", value = "&Value)
GetLabel(RowIndex, CellIndex).Text = Value
End Sub
Sub GetLabel(RowIndex As Int, CellIndex As Int) As Label
Dim row() As Object = TableView1.Items.Get(RowIndex)
Log("Cell Index = "&row(CellIndex))
Return row(CellIndex)
End Sub
Waiting for debugger to connect...
Program started.
Cell Index = Label@22135a[styleClass=label]'Item #005'
Cell Index = Label@3259ce[styleClass=label]'5'
rowIndex= 4, CellIndex = 1, value = a55
Cell Index = Label@3259ce[styleClass=label]'5'
Program started.
Cell Index = Label@22135a[styleClass=label]'Item #005'
Cell Index = Label@3259ce[styleClass=label]'5'
rowIndex= 4, CellIndex = 1, value = a55
Cell Index = Label@3259ce[styleClass=label]'5'
In my app I use the same code except the tableView is on a form that is opened on top of the main form and I get an error. This form has 2 tableViews on it.
B4X:
'....other code above
Dim value As String = lblAvailable.text
setTripCellValue(tripIndex,3,value)
End Sub
'Change cell values in the 'tvTrip' tableView
Sub setTripCellValue(RowIndex As Int, CellIndex As Int, Value As String)
Log("SelectdRow = "&RowIndex&", Cell Index = "&CellIndex&", value = "&Value)
GetTripLabel(RowIndex,CellIndex).Text = Value
End Sub
'
Sub GetTripLabel(RowIndex As Int, CellIndex As Int) As Label
Log("Row Index = "&RowIndex&", CellIndex = "&CellIndex)
Dim row() As Object = tvTrip.Items.Get(RowIndex)
Log("Cell Index = "&row(CellIndex))
Return row(CellIndex)
End Sub
SelectdRow = 0, Cell Index = 3, value = 10
Row Index = 0, CellIndex = 3
Cell Index = 10
Error occurred on line: 383 (paxSchedule)
java.lang.ClassCastException: java.lang.String cannot be cast to javafx.scene.control.Label
at b4j.CCShuttle.paxschedule._gettriplabel(paxschedule.java:783)
at b4j.CCShuttle.paxschedule._settripcellvalue(paxschedule.java:372)
at b4j.CCShuttle.paxschedule._btntripselect_action(paxschedule.java:356)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:613)
Row Index = 0, CellIndex = 3
Cell Index = 10
Error occurred on line: 383 (paxSchedule)
java.lang.ClassCastException: java.lang.String cannot be cast to javafx.scene.control.Label
at b4j.CCShuttle.paxschedule._gettriplabel(paxschedule.java:783)
at b4j.CCShuttle.paxschedule._settripcellvalue(paxschedule.java:372)
at b4j.CCShuttle.paxschedule._btntripselect_action(paxschedule.java:356)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:613)
The code is for all intensive purposes the same except for the table and variable names but outputs totally different log values and the second version errors. I have tried everything I can think of to find the problem.
Any ideas.
Thanks