我有一个使用 ActionBar Sherlock 的 ActionBar,我需要它来显示溢出,因为我有比空间更多的操作。但是,它不显示溢出图标。这是我的配置:
<?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>
这是设置它的代码:
@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;
}
我已经查看了 ActionBar Sherlock 中的演示,但我无法说出他们在获取溢出方面的不同之处与我正在做的事情。那么这里发生了什么,为什么它没有显示?