Android Question Common functions

mitsusdev

Member
Licensed User
Longtime User
I would add the same functions (actionbar, admod, ecc,ecc) in each activity without re-write the code.

how i have to write the code one time ?

into class molune, code module or .......

thanks
 
I have the same problem. I want to use ahactionbar (and others) in ALL my activities.
Can you give a us a short example of doing this as a class? Maybe a little Class which "generates, initialize and places" just a label!? Would be really great!
 
Upvote 0
I have the same problem. I want to use ahactionbar (and others) in ALL my activities.
Can you give a us a short example of doing this as a class? Maybe a little Class which "generates, initialize and places" just a label!? Would be really great!


I can... but can you explain to me HOW ahactionbar works well??? i have layout problem, with it! (search my post, i'm writing an example for your question - and read my signature, lol)
 
Upvote 0
Code: Copy
'Class module clsLayOutHelper
Sub Class_Globals
    Dim lbl As Label
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize

End Sub

Public Sub CreateLabel(HostPanel As Panel, _
                              Text As String, _
                              Left As Int, Right As Int, _
                              Width As Int, Height As Int, _
                              EventName As String)

    lbl.Initialize(EventName)
    lbl.Text = Text

    HostPanel.AddView(lbl, Left, Right, Width, Height)
End Sub


Then, in each Sub Globals Activity:

Code: Copy
Private mLayOutHelper As clsLayOutHelper

And:

Code: Copy
    mLayOutHelper.CreateLabel(Activity, "Hello", 10dip, 10dip, 120dip, 45dip, "")

(I have not tested it!)


Tested: don't works :)

Now works!
 
Last edited:
Upvote 0
thank erel

i have done a litte example project and work fine

but how i manage events of class ?

for example on action the click go to on event of class and don't go on event on activity.
 
Upvote 0
thanks, but the example project does'nt work, return:

java.lang.Exception: Sub button_click signature does not match expected signature.

when click on button
 
Upvote 0
Ahh it's one of those that works in the rapid debugger but not in legacy. The rapid debugger is more forgiving of type mismatches. Try this one.
 

Attachments

Upvote 0
Back
Top