1. 程式人生 > >actionbar中使用ActionProvider顯示自定義子選單

actionbar中使用ActionProvider顯示自定義子選單

[url]http://developer.android.com/guide/topics/ui/actionbar.html#ActionProvider[/url]
[url]http://stackoverflow.com/questions/19439106/cant-display-sub-menu-for-custom-actionprovider[/url]

Unfortunately, onPrepareSubMenu() is only called when onCreateActionView() returns null. Your solution (attaching a PopupMenu to the ImageView) will work, but since your ImageView is displaying an icon, you might consider just setting the icon in the menu XML and getting rid of the ImageView:

@Override
public View onCreateActionView(){
return null;
}