什么是处理主/详细流程菜单项的正确方法? [英] What is the proper way to handle menu items in a master/detail flow?

查看:129
本文介绍了什么是处理主/详细流程菜单项的正确方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建的基础上产生的Andr​​oid工作室例如一个主/详细流程。我使用 setHasOptionsMenu(真)让我的列表和详细的碎片有助于操作栏菜单。问题是,如果用户切换回从横向纵向那么细节片段仍然存在,仍然有助于操作栏菜单的时候真的只有列表中显示。什么是执行菜单项,这样当片段没有明显present他们不会流连的正确方法?

I built a master/detail flow based on the generated Android Studio example. I am using setHasOptionsMenu(true) to allow my list and detail fragments to contribute to the action bar menu. The problem is that if the user switches back to portrait from landscape then the detail fragment is still around and still contributing to the action bar menu when really only the list is showing. What is the proper way to implement menu items such that they won't linger when the fragment is not visibly present?

推荐答案

一个解决方案是使用的可见性()检查细节片段的 onCreateOptionsMenu 来有条件地膨胀菜单。

One solution is to use an isVisible() check in the detail fragment's onCreateOptionsMenu to conditionally inflate the menu.

这篇关于什么是处理主/详细流程菜单项的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆