坐落在一个Android应用程序的全局菜单

坐落在一个Android应用程序的全局菜单

本文介绍了坐落在一个Android应用程序的全局菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi everyone,

I know how to create a menu in my application with an icon and text on each "button" of the menu, but this menu is only visible on the activity where I created it...I would like to know if it is possible to create a global menu which would be accessible from all activities?thank you

解决方案

Not really. Since you didn't like the inheritance solution, the only alternative is to consolidate the menu creation and handling code in one place (e.g., static methods). You would still need to implement the callbacks on each activity (e.g., onHandleOptionsMenu()) and route them to the static common implementation.

这篇关于坐落在一个Android应用程序的全局菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 15:13