Contextual Action Bar in Honeycomb

2019-06-21 11:24发布

I'd like to change my Action Bar buttons in code according to whatever is selected on screen.

This is kind of like the Honeycomb Gmail app, where you can check a few mail items and get a different Action Bar with a different look too.

Any idea how I can do this?

1条回答
劳资没心,怎么记你
2楼-- · 2019-06-21 12:14

To obtain an action bar item, use the getActionBar() method within an activity. Once you have the ActionBar item, you can add and remove tabs using methods from within the ActionBar class.

The setCustomView() and setDisplayOptions() items will help tailor the action bar to a look more to your liking.

To add items to the action bar, you need to add them to the options menu. The action bar corresponds directly to the old menu (onCreateOptionsMenu() menu) of versions below 3.0. Take a look here.

查看更多
登录 后发表回答