在动作条溢出操作不显示动作、操作

由网友(晶莹泪眼)分享简介:我在使用的ActionBar福尔摩斯,我需要它来显示溢出,因为我比房多动作的动作条。但是,它并不显示溢出图标。下面是我的配置:I have an ActionBar using ActionBar Sherlock where I need it to display overflow because I have...

我在使用的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?

推荐答案

如果你有一个物理菜单键,溢出指示器不显示。这是由设计行为。请参阅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.

阅读全文

相关推荐

最新文章