AKJammer Active Member Licensed User Longtime User Nov 26, 2019 #1 I'm trying to use the XUtils B4XPlusMinus but am having a problem with initialization. I can get it to work when it's created with the designer, but when I try to create it in a tableview I keep getting the error: Code: Waiting for debugger to connect... Program started. Error occurred on line: 143 (B4XPlusMinus) java.lang.RuntimeException: Object should first be initialized (B4XView). at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:32) at anywheresoftware.b4a.objects.B4XViewWrapper.getNodeObject(B4XViewWrapper.java:103) at anywheresoftware.b4a.objects.B4XViewWrapper.setText(B4XViewWrapper.java:292) at b4j.example.b4xplusminus._setindex(b4xplusminus.java:326) at b4j.example.b4xplusminus._setstringitems(b4xplusminus.java:101) at b4j.example.main._loadtableview3(main.java:330) I think I'm doing the initialization just as I do the other objects I'm loading up, but I still get the error. Can anyone point me in the right direction? I've created a dummy project that shows what I'm doing. Thanks, Jim Attachments blah.zip blah.zip 3.7 KB · Views: 528
I'm trying to use the XUtils B4XPlusMinus but am having a problem with initialization. I can get it to work when it's created with the designer, but when I try to create it in a tableview I keep getting the error: Code: Waiting for debugger to connect... Program started. Error occurred on line: 143 (B4XPlusMinus) java.lang.RuntimeException: Object should first be initialized (B4XView). at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:32) at anywheresoftware.b4a.objects.B4XViewWrapper.getNodeObject(B4XViewWrapper.java:103) at anywheresoftware.b4a.objects.B4XViewWrapper.setText(B4XViewWrapper.java:292) at b4j.example.b4xplusminus._setindex(b4xplusminus.java:326) at b4j.example.b4xplusminus._setstringitems(b4xplusminus.java:101) at b4j.example.main._loadtableview3(main.java:330) I think I'm doing the initialization just as I do the other objects I'm loading up, but I still get the error. Can anyone point me in the right direction? I've created a dummy project that shows what I'm doing. Thanks, Jim
Erel B4X founder Staff member Licensed User Longtime User Nov 26, 2019 #2 You must use the designer to create custom views. You can create a layout with B4XPlusMinus and load it whenever you want to add one. Upvote 0
You must use the designer to create custom views. You can create a layout with B4XPlusMinus and load it whenever you want to add one.
AKJammer Active Member Licensed User Longtime User Nov 26, 2019 #3 Hmmm, Ok, so I create a B4XPlusMinus somewhere on the screen, make it invisible, then add one to the tableview like before? Sounds odd, but I'm willing to try. Is there any example of something like this? If I'm interpreting that wrong, would there be any way to add a custom view to a tableview as I'm doing with the other objects? Thanks Erel! Upvote 0
Hmmm, Ok, so I create a B4XPlusMinus somewhere on the screen, make it invisible, then add one to the tableview like before? Sounds odd, but I'm willing to try. Is there any example of something like this? If I'm interpreting that wrong, would there be any way to add a custom view to a tableview as I'm doing with the other objects? Thanks Erel!
Erel B4X founder Staff member Licensed User Longtime User Nov 27, 2019 #4 AKJammer said: Ok, so I create a B4XPlusMinus somewhere on the screen, make it invisible, then add one to the tableview like before? Click to expand... No. Create a pane for the item and call pane.LoadLayout to add the custom view. Upvote 0
AKJammer said: Ok, so I create a B4XPlusMinus somewhere on the screen, make it invisible, then add one to the tableview like before? Click to expand... No. Create a pane for the item and call pane.LoadLayout to add the custom view.
AKJammer Active Member Licensed User Longtime User Nov 27, 2019 #5 I guess I haven't work with panes enough to see how that works. I created another layout "1", and created a pane, then added the custom view to the pane. Then in my main program I added tried adding the pane to the tableview. It no longer errors, but it doesn't show up in the tableview either. Code: Case "spinner" Dim pn1 As Pane pn1.Initialize("spnEvent") pn1.LoadLayout("1") pn1.Tag = intex values(col) = pn1 Am I close? Attachments blah.zip blah.zip 4.9 KB · Views: 493 Upvote 0
I guess I haven't work with panes enough to see how that works. I created another layout "1", and created a pane, then added the custom view to the pane. Then in my main program I added tried adding the pane to the tableview. It no longer errors, but it doesn't show up in the tableview either. Code: Case "spinner" Dim pn1 As Pane pn1.Initialize("spnEvent") pn1.LoadLayout("1") pn1.Tag = intex values(col) = pn1 Am I close?
Erel B4X founder Staff member Licensed User Longtime User Nov 28, 2019 #6 You put spnRound inside an invisible pane so it doesn't appear. The layout should only include the custom view. You should also avoid loading layouts before setting the parent size. Better to write it like this: Code: Dim pn1 As B4XView = xui.CreatePanel("") 'xui is a global XUI object. pn1.SetLayoutAnimated(0, 0, 0, 140dip, 40dip) pn1.LoadLayout("1") spnRound.SetNumericRange(0, 100, 1) Upvote 0
You put spnRound inside an invisible pane so it doesn't appear. The layout should only include the custom view. You should also avoid loading layouts before setting the parent size. Better to write it like this: Code: Dim pn1 As B4XView = xui.CreatePanel("") 'xui is a global XUI object. pn1.SetLayoutAnimated(0, 0, 0, 140dip, 40dip) pn1.LoadLayout("1") spnRound.SetNumericRange(0, 100, 1)
AKJammer Active Member Licensed User Longtime User Nov 28, 2019 #7 Progress!! The pane wasn't invisible, but took it out so the custom view was the only thing in the layout and I was able to get it showing. But now that there is a Pane in the tableview, (showing the B4XPlusMinus), how do I extract the data out of it? Code: Sub btnShow_Click If myTableView.SelectedRow >= 0 Then Dim row() As Object = myTableView.SelectedRowValues Dim name As TextField = row(0) Dim pnRnd As Pane = row(1) Dim spnRnd As B4XPlusMinus = pnRnd.GetNode(0) 'Doesn't work Dim ok As CheckBox = row(2) Dim id As Int = row(3) Log(name.Text) Log(spnRnd.SelectedValue) Log(ok.Checked) Log(id) End If End Sub I can pull out the Pane, but trying to find the underlying object is a bit beyond me. Node didn't work, and I couldn't find any other Pane methods that would apply. So how would I be able to get/set the custom view value within code using the Pane? Upvote 0
Progress!! The pane wasn't invisible, but took it out so the custom view was the only thing in the layout and I was able to get it showing. But now that there is a Pane in the tableview, (showing the B4XPlusMinus), how do I extract the data out of it? Code: Sub btnShow_Click If myTableView.SelectedRow >= 0 Then Dim row() As Object = myTableView.SelectedRowValues Dim name As TextField = row(0) Dim pnRnd As Pane = row(1) Dim spnRnd As B4XPlusMinus = pnRnd.GetNode(0) 'Doesn't work Dim ok As CheckBox = row(2) Dim id As Int = row(3) Log(name.Text) Log(spnRnd.SelectedValue) Log(ok.Checked) Log(id) End If End Sub I can pull out the Pane, but trying to find the underlying object is a bit beyond me. Node didn't work, and I couldn't find any other Pane methods that would apply. So how would I be able to get/set the custom view value within code using the Pane?
Erel B4X founder Staff member Licensed User Longtime User Nov 29, 2019 #8 Code: Dim pnRnd As B4XView = row(1) Dim spnRnd As B4XPlusMinus = pnRnd.GetView(0).Tag 'XUI Views store a reference to the class in the base panel tag property. Upvote 0
Code: Dim pnRnd As B4XView = row(1) Dim spnRnd As B4XPlusMinus = pnRnd.GetView(0).Tag 'XUI Views store a reference to the class in the base panel tag property.
AKJammer Active Member Licensed User Longtime User Nov 29, 2019 #9 That was it. Thanks again Erel. I'm going to be using this in my first B4A app as well. Needed a way for people to make quick selections in minimum space. I'll probably have more questions as I move from B4J to B4A, but this environment has been wonderfully productive. Enjoy your Holidays! Jim Upvote 0
That was it. Thanks again Erel. I'm going to be using this in my first B4A app as well. Needed a way for people to make quick selections in minimum space. I'll probably have more questions as I move from B4J to B4A, but this environment has been wonderfully productive. Enjoy your Holidays! Jim