Your SlideShare is downloading. ×
0
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
The Action Bar: Front to Back
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

The Action Bar: Front to Back

4,299

Published on

Presentation from the 2011 Android Open conference

Presentation from the 2011 Android Open conference

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,299
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
70
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. The Action Bar: Front to Back Copyright © 2011 CommonsWare, LLC
  • 2. Action Bar and System Bar Action Bar System Bar Copyright © 2011 CommonsWare, LLC
  • 3. Targeting Honeycomb● <uses-sdk android:targetSdkVersion=“11”>● Effects – Action bar added – Options menu hoisted from status bar soft button to normal action bar “overflow” position – Holographic theme for widgets Copyright © 2011 CommonsWare, LLC
  • 4. Toolbar Buttons● Toolbar Buttons = Options Menu Items● Add android:showAsAction to <item> in menu resource – ifRoom to indicate it can remain an options menu item if there is no room – withText if you want icon & title● Backwards-compatible automatically – Attribute ignored on older Android versions Copyright © 2011 CommonsWare, LLC
  • 5. Copyright © 2011 CommonsWare, LLC
  • 6. Copyright © 2011 CommonsWare, LLC
  • 7. Toolbar Widgets● Substitute Own Inflated Layout for Standard Toolbar Button – Add android:actionLayout to <item> in menu resource – Call getActionView() on MenuItem to configure at runtime ● New method in API Level 11 ● Requires special care to remain backwards- compatible Copyright © 2011 CommonsWare, LLC
  • 8. Copyright © 2011 CommonsWare, LLC
  • 9. Copyright © 2011 CommonsWare, LLC
  • 10. Home Affordance● Fancy Term for “Icon On The Left” – Default = activity icon – Optional android:logo in <application> to supply alternative image● Virtual menu choice: android.R.id.home – Handle in onOptionsItemSelected()● setDisplayHomeAsUpEnabled() – Adds arrowhead Copyright © 2011 CommonsWare, LLC
  • 11. Navigation Modes● Tabs – Replacement for TabHost – Use setNavigationMode() to enable tabs – Call addTab() on ActionBar for each tab ● Supply a TabListener – Process tab events ● Selected ● Unselected ● Reselected Copyright © 2011 CommonsWare, LLC
  • 12. Copyright © 2011 CommonsWare, LLC
  • 13. Copyright © 2011 CommonsWare, LLC
  • 14. Copyright © 2011 CommonsWare, LLC
  • 15. Navigation Modes● “List” – Puts Spinner in navigation area of action bar – Call setNavigationMode() to enable this mode – Call setListNavigationCallbacks() to supply SpinnerAdapter and an OnNavigationListener – Respond to selection events Copyright © 2011 CommonsWare, LLC
  • 16. Copyright © 2011 CommonsWare, LLC
  • 17. Copyright © 2011 CommonsWare, LLC
  • 18. Copyright © 2011 CommonsWare, LLC
  • 19. Navigation Modes● setCustomView() – You supply your own View or layout resource ID – Used in the navigation space on the action bar, instead of tabs or Spinner – Example: AutoCompleteTextView for browser – getCustomView() to retrieve inflated layout for runtime configuration Copyright © 2011 CommonsWare, LLC
  • 20. Action Modes● Alternate Action Bar for Contextual Actions – Operations on multiple selections – Replacement for context menu Copyright © 2011 CommonsWare, LLC
  • 21. Action Modes● DIY Action Mode – Call startActionMode() with ActionMode.Callback – Configure ActionMode in onCreateActionMode() – onActionItemClicked() if user clicks a toolbar button – finish() the ActionMode when done Copyright © 2011 CommonsWare, LLC
  • 22. Action Modes● Automatic Multiple-Choice Action Mode – CHOICE_MODE_MULTIPLE_MODAL and an appropriate row layout – Long-press checks item, enables remaining checkboxes, toggles on action mode with your supplied MultiChoiceModeListener callback ● Serves as ActionBar.Callback, plus onItemCheckedStateChanged() for check/uncheck events Copyright © 2011 CommonsWare, LLC
  • 23. Copyright © 2011 CommonsWare, LLC
  • 24. Styles and Themes● Theme.Holo / Theme.Holo.Light – Standard themes, standard color scheme● Can Style the Action Bar – Lightly-documented – Nick Butcher blog post: http://goo.gl/wUSxN ● Does not work – cannot inherit from private theme ● Carlos Sessa workaround: http://goo.gl/TNN0S Copyright © 2011 CommonsWare, LLC
  • 25. What About the Phone?● ActionBarSherlock – Modified Android Compatibility Library with backwards-compatible action bar● Ice Cream Sandwich Copyright © 2011 CommonsWare, LLC
  • 26. Source Code● http://github.com/commonsguy/cw-android – Menus/InflationBC project● http://github.com/commonsguy/cw-advandroid – Honeycomb/* projects Copyright © 2011 CommonsWare, LLC

×