Android的选项菜单始终紧贴 [英] android options menu always close

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

问题描述

我想知道如何prevent菜单栏中的关闭。

  @覆盖
公共无效onOptionsMenuClosed(菜单菜单){}

在活动开始我打开菜单,并希望它继续开放。

 新的处理程序()。postDelayed(新的Runnable(){
        公共无效的run(){
            openOptionsMenu();
        }
    },1000);


解决方案

您不能保留选项菜单打开,它总是会那样做。但是你可以做的是在layout.xml创建自己的自定义菜单和可见性设置为不见了。然后,覆盖的onkeydown()方法和监听菜单键presses。如果是pressed,选项菜单将被设置为打开/关闭(可见/不可见),取决于其当前状态。这样,你可以控制,如果选项菜单将继续开放,甚至没有接触了。

I would like to know how to prevent the menu bar from closing.

@Override
public void onOptionsMenuClosed(Menu menu) {

}

When the activity starts I open the menu and want it to stay open.

    new Handler().postDelayed(new Runnable() {
        public void run() {
            openOptionsMenu();
        }
    }, 1000);

解决方案

You cannot keep the Options Menu open and it will always act that way. But what you can do is create your own custom menu in a layout.xml and set the visibility to GONE. Then, override the onKeyDown() method and listen for presses of the menu key. If it is pressed, the options menu will be set to open/close (VISIBLE/INVISIBLE) depending on its current state. That way, you can control if the options menu will remain open or not even after touch.

这篇关于Android的选项菜单始终紧贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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