开发者

Disable menu when login as guest on Android

开发者 https://www.devze.com 2023-04-08 10:12 出处:网络
I have an app where the user is able to choose to login with the ID or only as a guest. I set the default of the app that after the user chooses either to login or with I开发者_如何转开发D or not, the

I have an app where the user is able to choose to login with the ID or only as a guest. I set the default of the app that after the user chooses either to login or with I开发者_如何转开发D or not, there is a menu on the activity.

What I wanna do is, when the user login as guest, the menu is disabled. So when the user clicks the 'menu' button on his phone, nothing will show up.

Can someone help me with the code?


I think it's very useful to read the API documentation on first, but still, here is your answer:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Create your menu code

return !isGuestMode;
}

The return value of onCreateOptionsMenu determines whether a manu should be displayed or not.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号