Custom views in actionbar

坚强是说给别人听的谎言 提交于 2019-12-06 05:47:12

问题


I have an action bar. One of the items in the actionbar is for notifications. I want to add a little icon in the top right of the actionbar item which represents how many notifications the user currently has.

I went ahead and made a custom layout for the action bar item. Went to go add it and to my surprise there is no way for me to add a custom view as a button on a Action bar.

I am using Actionbar-Sherlock for compatibility to older device.

This is what I am going for:


回答1:


You're looking for ActionProvider. Here you can supply your own views and listeners.

Check out the ABS demo, https://github.com/JakeWharton/ActionBarSherlock/blob/master/actionbarsherlock-samples/demos/src/com/actionbarsherlock/sample/demos/ActionProviders.java



来源:https://stackoverflow.com/questions/12554524/custom-views-in-actionbar

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