在动作条溢出操作不显示 [英] Overflow Actions on ActionBar not showing

查看:136
本文介绍了在动作条溢出操作不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用的ActionBar福尔摩斯,我需要它来显示溢出,因为我比房多动作的动作条。但是,它并不显示溢出图标。下面是我的配置:

I have an ActionBar using ActionBar Sherlock where I need it to display overflow because I have more actions than room. But, it doesn't show the overflow icon. Here is my configuration:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_search"
      android:icon="@drawable/action_search"
      android:title="@string/menu_search"
      android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/menu_library"
      android:icon="@drawable/hardware_headphones"
      android:title="@string/my_music"
      android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/menu_downloads"
      android:icon="@drawable/av_download"
      android:title="@string/downloads"
      android:showAsAction="ifRoom|withText"/>
</menu>

这里是code来进行设置:

And here is code to set it up:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater menuInflater = getSupportMenuInflater();
    menuInflater.inflate(R.menu.shopping_menu, menu);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    searchMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            startActivity(new Intent(ShopActivity.this, SearchDialog.class));
            return false;
        }
    });
    MenuItem downloadMenuItem = menu.findItem(R.id.menu_downloads);
    downloadMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            startActivity( new Intent(ShopActivity.this, DownloadQueueActivity.class) );
            return false;
        }
    });
    MenuItem myMusicItem = menu.findItem(R.id.menu_library);
    myMusicItem.setOnMenuItemClickListener( new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            startActivity(new Intent(ShopActivity.this, MyMusicActivity.class));
            return false;
        }
    });

    return true;
}

我看过了在动作条福尔摩斯的演示,但我不能告诉他们做什么不同的,以获得溢出不是我在做什么。因此,这里发生了什么,为什么它没有显示?

I've looked over the demos in ActionBar Sherlock, but I can't tell what they do differently to get the overflow than what I'm doing. So what's happening here why its not showing?

推荐答案

如果你有一个物理菜单键,溢出指示器不显示。这是由设计行为。请参阅<一href="http://stackoverflow.com/questions/8758263/how-to-force-overflow-menu-on-android-actionbar-compat?rq=1">here上问另一个问题的更多细节。

If you have a physical menu key, the overflow indicator does not show. That is a behaviour by design. See here for more details on another question asked.

这篇关于在动作条溢出操作不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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