views:

45

answers:

1

Hi,

I have 10-15 activities in my project. I want to have the option menu mostly in all Activities. Then is their any way we can do it at one place and it appears in all activities.

Also, I will like to hide the option menu in some. So, is it possible or I have to write option menu code in all activities.

Regards

Sunil

+1  A: 

I don't have access to my development machine (as of now), so this answer is purely a shot in dark. I've not tried it though, i will once i get time.

So here goes, Create a Class (say BaseActivity) that extends Activity, and override the Options Menu Functions.....

Now, in the other 15-16 Activities, instead of extending an Activity, You should extend BaseActivity.

This way, all your activities derive the Options Menu...for Activities where you want the Options Menu Disabled, you can override it again in the Actual Activity...

Hopefully, it doesn't give you problems in the Manifest Files...

Hope it works, i'll try it soon and let you know... :)

st0le
Even i thought about that but I already have a customactivity for setting the title bar in all activities. Will try implementing it in that itself.
sunil
yes, please do, it ought to work. Also report your results. :)
st0le