简体   繁体   中英

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; if you return false it will not be shown.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM