Android Question stdactionbar for all activities

Stern0m1

Member
Licensed User
How do I make the same stdactionbar for all activities in an app without copy pasting?

Thanks
 

Stern0m1

Member
Licensed User
You can implement all the relevant code in a class and use an instance of this class in each of the activities.

I am trying to implement this but I am getting stuck on the following.
I am trying to have the same actionbar with menu items in all activities. But im not sure how to have the eventname_click trigger a sub written in the class.
My code:

B4X:
Public Sub Initialize(activity As Activity)
    AB.Initialize("")
    activity.AddMenuItem3("Add Timer", "addtimer", Null, False)
    activity.AddMenuItem3("Set Mac Id", "mac", Null, False)
    activity.AddMenuItem3("Set Serial Number", "serial", Null, False)
   
End Sub

When add timer is clicked its looking for addtime_click in the actual activity not in the class.

Any suggestions?

Thanks
 
Upvote 0

Stern0m1

Member
Licensed User
B4X:
    AB.Initialize("bar")
    AB.NavigationMode = AB.NAVIGATION_MODE_LIST
    AB.SetListItems(Array As String("Add Timer", "Set Mac Id", "Set Serial Number"))

This works, But I want a menu with the 3 little dots in the corner. I get it by setting @android:style/Theme.Holo.Light and the activity.addmenuitem3.
 
Upvote 0

Stern0m1

Member
Licensed User
I realized my question was phrased wrong. This has nothing to with an actionbar. My question just is how to implement addmenuitem in a class.

Thanks
 
Upvote 0
Top