拦截 onOptionsItemSelected
我有一个顶级 TabHost 实现 onCreateOptionsMenu 方法。我希望子活动(选项卡内的子活动)能够通过 onOptionsItemSelected 拦截选项菜单。例如,在选项菜单中,我有一个名为“编辑注释”的项目,在一个选项卡中有一个包含所有注释列表的 ListView。我希望能够在整个应用程序中查看“编辑注释”项,但顶级 TabActivity 不知道注释的标题或 id 等信息。
I have a top level TabHost that implements the onCreateOptionsMenu method. And I want sub-activities (those within the tabs) to be able to intercept the options menu via onOptionsItemSelected. Like for example, in the options menu I have an item called, "Edit Note" and in one tab there is a ListView with a list of all the notes. I want the "Edit Note" item to be able to be viewed throughout the application, but the top level TabActivity doesn't know information such as title or id of the note.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对选项卡进行子类化,并让父级调用 OnOptionsItemSelected 中的活动子级,使其有机会首先处理它。
Subclass the tabs, and have the parent call down to the active child in the OnOptionsItemSelected to give it the chance to handle it first.