Q:

Action bar from main activity to second

I have a problem with action bar. I have a action bar in main activity which is creating in onCreateOptionsMenu(Menu menu). Items I am adding in this method too. Now I want to that when I click on my item in second activity was the same action bar. I want that when I copy and paste code from this method to method in second activity it work but I don't want to copy this code because I add a lot of items. This is possible to use action bar from first activity in second activity?

A:

Yes, it is possible. I have three possible solutions: 

Add the action items via xml http://developer.android.com/guide/topics/ui/actionbar.html#ActionItems
Your second activity could extend your MainActivity (or better, create an abstract base activity for both, which only creates the menu).
Extract the menu creation in a helper class and call the same method from each activity.

All three ways are possible, but I would prefer the first one. 

