Other Callsub2 problem!!!

AbbasMohammed

Member
Licensed User
Longtime User
Hi, the problem iam facing here is htis:

CallSub2(Main,"show",pan)

is not working, and when i go to debug mode it dosnt call the show sub in main, so i need your help to show the panel on mobile screen.

Main:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
  
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Public pan As Panel
    Public Father As ImaginaryMain
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Father.Initialize
    pan.Initialize("hi")
    Father.show
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub show(pl As Panel)
    Activity.Addview(pan, 0,0,100%x,100%y)
End Sub

ImaginaryMain:

B4X:
'Class module
Sub Class_Globals
    Private pan As Panel
    Private page1 As page
    Private pgdisp As pageidsplay
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
'    page1.Initialize
'    pgdisp.Initialize(Me)
    pan.Initialize("xxx")
    pan.Color=Colors.Red
End Sub

public Sub show
    CallSub2(Main ,"show",pan)
End Sub
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
Hi, the problem iam facing here is htis:

CallSub2(Main,"show",pan)

is not working, and when i go to debug mode it dosnt call the show sub in main, so i need your help to show the panel on mobile screen.

Main:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Public pan As Panel
    Public Father As ImaginaryMain
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Father.Initialize
    pan.Initialize("hi")
    Father.show
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub show(pl As Panel)
    Activity.Addview(pan, 0,0,100%x,100%y)
End Sub

ImaginaryMain:

B4X:
'Class module
Sub Class_Globals
    Private pan As Panel
    Private page1 As page
    Private pgdisp As pageidsplay
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
'    page1.Initialize
'    pgdisp.Initialize(Me)
    pan.Initialize("xxx")
    pan.Color=Colors.Red
End Sub

public Sub show
    CallSub2(Main ,"show",pan)
End Sub


What exactly are you trying to do? there are many ways to skin a cat.
 
Upvote 0

AbbasMohammed

Member
Licensed User
Longtime User
i have a data classes that contain a data i got from db and i made a disply class just to disply those data so i need to create the objects first then send the objects data to that disply page , then i use next prev buttons to disply other objects data
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Ok, so you have a class that retrieves and organizes Data from a DataBase, and you want to pass a completely Formed Layout to a panel In the main activity, correct?

you need to understand that a class usually does not call activity subs, its main purpose is to return values or execute funtions.

for instance, if you want to show a panel created by your class you shoul do something like this:

class code:
B4X:
Sub Class_Globals
    Dim DataPanel As Panel
    Dim DataField As Label
End sub

Sub Initialize (Target as Panel) 'Target is the calling activity
    DataPanel.Initialize("")
    DataField.Initialize("")
    DataPanel.AddView(DataFIeld, (.......))' here we add the DataField to the DataPanel
    Target.AddView(DataPanel, (.......))' here you place your DataPanel in the Calling Activity, setting Left,Top,etc
    (....)
    'the rest of the data manipulation can be done here or dispatched for other Class Subs
End Sub

Then in Main....

Define a Class object from your Class, usualy in Globals, like

B4X:
Dim MyDataClass as DataClass 'Here DataClass is the name of your Class and MyDataClass is and object of it

then to make the DataPanel Appear in the activity,

B4X:
MyDataClass.Initialize(Activity)

That's it

Remember, this is just for exemplification purposes, my code is incomplete in some lines and may even be misspelled or erroneous.
Play with it, adapt it, read some Classes tutorials...
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
you can do it either way, but for you specific case, I think its easier to return the whole panel to the activity instead of populating an Activity already created panel.
you should also have a look at the pager class, I think it suites your needs very well, and has the "Next/Previous" thing already implemented
 
Upvote 0
Top