Adam J
Adam J

Reputation: 183

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);
}

Upvotes: 0

Views: 1791

Answers (1)

user3002166
user3002166

Reputation: 730

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.

Upvotes: 1

Related Questions