Android: Custom view for a menu item

[亡魂溺海] 提交于 2019-11-30 16:53:54

问题


I want to be able to specify a custom view for a MenuItem.

I want to display an indicator on a shopping cart menu item in the action bar displaying how many items are in the cart currently.

Is the only way that I can do this is through adding a custom view instead of utilising the MenuItem lifecycle etc.?


回答1:


To use a custom view on a MenuItem call setActionView(View view).

You can supply either an already inflated view or a layout resource ID.



来源:https://stackoverflow.com/questions/17332584/android-custom-view-for-a-menu-item

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!