ScrollView Table Error

Bryan

Member
Licensed User
Longtime User
I am pretty sure I am using this the right way but here is my problem.

This is basically what is causing the problem. Other code removed to make it simplier. I am starting with the table example given on the site. I just want to receive the string from the last row, first Column. This works if I give it a direct number such as EventStr = GetCell(415, 0).
It fails if I try to use a variable as shown below


B4X:
Sub Globals
   Dim EventStr As String
   Dim NumRows As Int
End Sub


Sub GetLastEvent
NumRows = NumberOfRows
EventStr = GetCell(NumRows, 0)
End Sub


Sub GetCell(Row As Int, Col As Int) As String
   Return GetView(Row, Col).Text
End Sub

Sub NumberOfRows As Int
   Return Table.NumberOfViews / NumberOfColumns
End Sub

'Returns the label in the specific cell
Sub GetView(Row As Int, Col As Int) As Label
   Dim l As Label
   l = Table.GetView(Row * NumberOfColumns + Col)
   Return l
End Sub



Debug Listing

B4X:
Installing file.
PackageAdded: package:anywheresoftware.b4a.table
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main_getview (B4A line: 165)
l = Table.GetView(Row * NumberOfColumns + Col)
java.lang.RuntimeException: Object should first be initialized (View).
Did you forget to call Activity.LoadLayout?
   at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:45)
   at anywheresoftware.b4a.table.main._getview(main.java:586)
   at anywheresoftware.b4a.table.main._getcell(main.java:536)
   at anywheresoftware.b4a.table.main._getlastevent(main.java:558)
   at anywheresoftware.b4a.table.main._ok_click(main.java:896)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:155)
   at anywheresoftware.b4a.BA.raiseEvent(BA.java:151)
   at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:59)
   at android.view.View.performClick(View.java:2538)
   at android.view.View$PerformClick.run(View.java:9152)
   at android.os.Handler.handleCallback(Handler.java:587)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:130)
   at android.app.ActivityThread.main(ActivityThread.java:3687)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:507)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
   at dalvik.system.NativeStart.main(Native Method)
java.lang.RuntimeException: Object should first be initialized (View).
Did you forget to call Activity.LoadLayout?

Thanks
Bryan
 
Last edited:
Top