[英]Why does onCreateOptionsMenu(Menu menu) return a boolean?
I'm confused as to why it returns a boolean here when within the last line of code. 我很困惑为什么在代码的最后一行中它会在此处返回布尔值。 What's the use of this and why does it matter?
这有什么用,为什么重要?
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return super.onCreateOptionsMenu(menu);
}
From documentation for this method: 从有关此方法的文档中:
Returns boolean You must return true for the menu to be displayed;
返回布尔值要显示菜单,必须返回true;否则,返回false。 if you return false it will not be shown.
如果返回false,则不会显示。
To my understanding, this is to confirm that menu was created correctly, it is populated only with valid elements, so it can safely be used. 据我了解,这是为了确认菜单创建正确,仅在菜单中填充了有效元素,因此可以安全地使用菜单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.