Android Question Using ScrollView in B4A and B4J (B4XPages project)

asales

Expert
Licensed User
Longtime User
I'm trying to create a cross platform project.
I have a layout with a long panel that I load in another layout into a scrollview.

This is the code:
B4X:
Private pnlProfile As B4XView
Private scroll1 As B4XView

Private Sub B4XPage_Created (Root1 As B4XView)
    Root.LoadLayout("layScroll")
    scroll1.GetView(0).LoadLayout("profile")
    scroll1.ScrollViewContentHeight = pnlProfile.Height
End Sub
It works when I compile in B4A, but in B4J I get this error:
B4X:
java.lang.RuntimeException: java.lang.ClassCastException: class javafx.scene.control.ScrollPane cannot be cast to class javafx.scene.layout.Pane (javafx.scene.control.ScrollPane is in module javafx.controls of loader 'app'; javafx.scene.layout.Pane is in module javafx.graphics of loader 'app')
How can I fix it?

Thanks in advance for any tips.
 

asales

Expert
Licensed User
Longtime User
B4X:
 scroll1.ScrollViewInnerPanel.GetView(0)
I try this:
B4X:
Root.LoadLayout("layScroll")
scroll1.ScrollViewInnerPanel.GetView(0).LoadLayout("profile")
but now I get this errors:
B4X:
B4J:
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (B4XView).

B4A:
java.lang.RuntimeException: Object should first be initialized (View).
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Sorry it should be:
B4X:
scroll1.ScrollViewInnerPanel.LoadLayout("profile")
Thanks, but still works only in B4A.

Here my B4X Project (B4A and B4J).
In B4J the error remains:
B4X:
java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (B4XView).
 

Attachments

  • profile_form.zip
    19.9 KB · Views: 67
Upvote 0

PaulMeuris

Active Member
Licensed User
I did some testing with this code:
B4X:
If scroll1.IsInitialized = True Then Log("scroll1 is initialized")
scroll1 is initialized
But the scroll1 B4XView still gave the same error.
So here is the code with a ScrollPane (B4J):
using B4J ScrollPane:
    'Private scroll1 As B4XView   
    Private scroll1 As ScrollPane

    'If scroll1.IsInitialized = True Then Log("scroll1 is initialized")
    'scroll1.ScrollViewInnerPanel.LoadLayout("myprofile")   
    'scroll1.ScrollViewContentHeight = pnlData.Height
    scroll1.LoadLayout("myprofile",scroll1.PrefWidth,scroll1.prefHeight)
    scroll1.InnerNode.PrefHeight = pnlData.Height
This is the result:

In the Visual Designer i have stretched the scroll1 ScrollPane to cover the form width and height. The anchors remained.
The comments in the code were the original lines with a B4XView.
The question still remains why the B4XView throws this error... can somebody explain this?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…