Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的 android 应用程序中,选项菜单应该在每个 UI 中都可用。所以我需要将这些代码分离到一个单独的类文件中,而不是在每个 Activity 中重复相同的代码。我怎样才能在 Android 中做到这一点?
一种方法是从本身派生自“活动”的自定义类继承。在这个基类中,您拥有选项菜单的通用代码。