在Android的活动相同的选项菜单选项、菜单、Android

由网友(暗。殇)分享简介:我有10-15的活动在我的项目。我想有选项菜单大多在活动。然后是他们的任何方式,我们可以在一个地方做,它出现在所有的活动。I have 10-15 activities in my project. I want to have the option menu mostly in all Activities. Th...

我有10-15的活动在我的项目。我想有选项菜单大多在活动。然后是他们的任何方式,我们可以在一个地方做,它出现在所有的活动。

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.

另外,我会想隐藏一些选项菜单。因此,有可能还是我必须写选项菜单code中的所有活动。

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.

问候

苏尼尔

推荐答案

我没有访问我的开发机器(截至目前),所以这个答案纯粹是在黑暗中摸索。 我还没有尝试过,虽然,我会一次,我得到的时间。

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.

所以这里去,创建一个类(比如 BaseActivity ),扩展活动,并覆盖选项菜单功能.....

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

现在,在其他15-16的活动,而不是延伸的活动,你应该继承的 BaseActivity

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... :)

阅读全文

相关推荐

最新文章