如何隐藏选项菜单? [英] How to hide option menu?

查看:85
本文介绍了如何隐藏选项菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用选项选择菜单项,附加三个项(共享,登录,注销)是选择登录项,如果登录同时隐藏登录项,则转到登录活动登录社交符号(Facebook或google)中的任何一个(显示登录名)项目,如果退出社交符号显示登录项目菜单,则属于同一类型,请帮助我...

I am using option selected menu item, attached three item (share, login, logout) am select login item, go login activity login social sign (Facebook or google) any one, if login hide login item at same time show logout item, this same type if logout the social sign show login item menu, please help me...

推荐答案

步骤:1)menu.xml定义了所有三个菜单项.登录,注销和共享之后,默认情况下使注销可见性为

step:1) menu.xml define all three menu item. login ,logout and share after that make logout visibility to false by default

android:visible="false"

并使其余两个项目可见.可选,因为默认情况下所有项目在android中都是可见的

and make remaining two items visible.its optional because by default all items are visible in android

步骤:2)当您登录时,Activity会对该xml进行充气,而无需在活动中进行任何更改 此时,我们仅显示登录和共享"菜单项,并且我们已经将xml中的logOff项目可见性设置为false.

Step:2)when you are in login Activity inflate that xml.and no need to make any change in activity at these point we are showing login and share menu item only and we have already made logOff item visibility to false in the xml .

步骤:3)当您处于主要活动(登录活动后显示的活动)时

step:3) when you are in main activity(activity that you are showing after login activity) do these

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    inflater.inflate(R.menu.menu, menu);

    MenuItem item = menu.findItem(R.id.login_id);
            item.setVisible(false);//
    MenuItem item = menu.findItem(R.id.logOff_id);
            item.setVisible(true);
    super.onCreateOptionsMenu(menu, inflater);
}

此时,您将获得注销和共享,因为我们已将登录菜单项的可见性设置为false.

at these point you will get logOff and share because we have made login menu item visibility to false .

这篇关于如何隐藏选项菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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