Android Question rounting message from activity to object

Discussion in 'Android Questions' started by Roberto P., May 22, 2015.

  1. Roberto P.

    Roberto P. Well-Known Member Licensed User

    hello to all
    I am creating an object that allows me to create a common basis for the activity (why B4A not support class inheritance).

    I need help to send messages from the menu class activity linked object.

    In practice, the object I create the menu of Activity but I want the message "remain" in the subject without having to send in the same class.

    Sub Class_Globals

    Private m_Parent As Activity
    Private     bar                     As StdActionBar
    Private bmpNuova, bmpChiudi, bmpSalva, bmpMenu As Bitmap
    End Sub

    'Initializes the object. You can add parameters to this method if needed.
    Public Sub Initialize(aActivity As Activity, aSubTitle As String)

        m_Parent        =    aActivity

    End Sub
    ' creo interfaccia utente
    Sub CreateUI

        bar.ShowUpIndicator     = 
        bmpChiudi                         = 
    LoadBitmapFile.DirAssets, "img/indietro.png" )
        bmpNuova                            = 
    LoadBitmapFile.DirAssets, "img/nuovo.png" )
        bmpSalva                            = 
    LoadBitmapFile.DirAssets, "img/salva.png" )
    "Nuova Anagrafica",        "cmdNuova",                bmpNuova,     True)
    "Salva Documento",        "cmdSalva",                bmpSalva,     True)
    "Chiudi",                            "cmdChiudi",            bmpChiudi,     True)
    End Sub
    Sub bar_ButtonClicked
    End Sub
    Sub cmdChiudi_Click
    End Sub
    Sub cmdNuova_Click
    End Sub
    #Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
    #End Region

    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.

    Dim m_BaseClass As CActivityBase

    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 cmdChiudi_click
        'I wish that this message is sent to the object and not the activity or object that is turned on automatically.
    End Sub
  2. Erel

    Erel Administrator Staff Member Licensed User

    Note that you need to use the new Activity_ActionBarHomeClick event instead of Bar_ButtonClicked event.

    The activity events (including the menu events) will always be raised on the activity module.
  3. Roberto P.

    Roberto P. Well-Known Member Licensed User

    hello Erel,
    thanks for the first tip and the response. I will do otherwise.

    Sorry if I insist with the same question: do you believe that there will be the ability to manage the inheritance with B4A? Or the ability to create a base class in Java a personalized Activity from which to create the Activity of B4A? Even in future versions?

    Thanks again.
  4. Erel

    Erel Administrator Staff Member Licensed User

    Currently it is not possible to create a base class for the activity in B4A. It might be possible with Java and the Extends attribute.
    I don't recommend you to use it as this is not the standard way to implement activities in B4A and will most probably do more harm than good.

    It should be simple to create a class that implements the common features in all the activities. All you need to do is to delegate two or three event subs to the class (all the menu items can use the same event sub).
  5. Roberto P.

    Roberto P. Well-Known Member Licensed User

    hello Erel,
    I wanted to avoid having to implement the same for each sub activity. I will do so, until it will be available otherwise.

    thanks for the reply.
  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