Other Callsub2 problem!!!

Discussion in 'Android Questions' started by AbbasMohammed, Jul 1, 2015.

  1. AbbasMohammed

    AbbasMohammed Member Licensed User

    Hi, the problem iam facing here is htis:


    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.


    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:
    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

    '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)
    End Sub

    public Sub show
    CallSub2(Main ,"show",pan)
    End Sub
    Last edited: Jul 1, 2015
  2. Cableguy

    Cableguy Expert Licensed User

    You should use callsubdelayed. Calsub does not work with activities that are not in foreground
  3. AbbasMohammed

    AbbasMohammed Member Licensed User

    but i need to disply page instantly, is there any way to do that like starting another activity or so???
  4. Cableguy

    Cableguy Expert Licensed User

    What exactly are you trying to do? there are many ways to skin a cat.
  5. AbbasMohammed

    AbbasMohammed Member Licensed 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
  6. Cableguy

    Cableguy Expert Licensed 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:
    Sub Class_Globals
    Dim DataPanel As Panel
    Dim DataField As Label
    End sub

    Sub Initialize (Target as Panel'Target is the calling activity
        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

    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,

    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...
    AbbasMohammed likes this.
  7. AbbasMohammed

    AbbasMohammed Member Licensed User

    thank you very much for your help ,but arnt you sending the activity while the class waits for panel as argument??
  8. Cableguy

    Cableguy Expert Licensed 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
    Erel and AbbasMohammed like this.
  9. AbbasMohammed

    AbbasMohammed Member Licensed User

    many thanks for your kind support....your solution is working:)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice