SlideShare a Scribd company logo
The Action Bar:
 Front to Back
     Copyright © 2011 CommonsWare, LLC
Action Bar and System Bar

                                            Action Bar




                                            System Bar




        Copyright © 2011 CommonsWare, LLC
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
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
Copyright © 2011 CommonsWare, LLC
Copyright © 2011 CommonsWare, LLC
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
Copyright © 2011 CommonsWare, LLC
Copyright © 2011 CommonsWare, LLC
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
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
Copyright © 2011 CommonsWare, LLC
Copyright © 2011 CommonsWare, LLC
Copyright © 2011 CommonsWare, LLC
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
Copyright © 2011 CommonsWare, LLC
Copyright © 2011 CommonsWare, LLC
Copyright © 2011 CommonsWare, LLC
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
Action Modes
●   Alternate Action Bar for Contextual Actions
    –   Operations on multiple selections
    –   Replacement for context menu




                      Copyright © 2011 CommonsWare, LLC
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
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
Copyright © 2011 CommonsWare, LLC
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
What About the Phone?
●   ActionBarSherlock
    –   Modified Android Compatibility Library with
        backwards-compatible action bar
●   Ice Cream Sandwich




                      Copyright © 2011 CommonsWare, LLC
Source Code
●   http://github.com/commonsguy/cw-android
    –   Menus/InflationBC project


●   http://github.com/commonsguy/cw-advandroid
    –   Honeycomb/* projects




                        Copyright © 2011 CommonsWare, LLC

More Related Content

PDF
The Action Bar: Front to Back
PDF
Introducing Honeycomb
PDF
Restaurant Bar Design
PPS
Interior Design Portfolio
PDF
Commercial Kitchen Design and Planning
PPTX
Juice Bar Business Plan - Cold Pressed Juices and Others
PPT
Designing a commercial kitchen
PPTX
Business plan_Restaurant
The Action Bar: Front to Back
Introducing Honeycomb
Restaurant Bar Design
Interior Design Portfolio
Commercial Kitchen Design and Planning
Juice Bar Business Plan - Cold Pressed Juices and Others
Designing a commercial kitchen
Business plan_Restaurant

Similar to The Action Bar: Front to Back (20)

PDF
From Android to the Mobile Web
KEY
Google I/O 2011, Android Honeycomb Highlights
PDF
Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3
PDF
Android Workshop 2013
PDF
01 06 - android programming basics
PPTX
User interface customization for aem6 circuit
PPTX
UI Customization in AEM 6.0
PPT
Android ui patterns
PPT
Android ui patterns
PDF
Top Tips for Android UIs - Getting the Magic on Tablets
PDF
MOPCON 2014 - Best software architecture in app development
PDF
User Interface customization for AEM 6
PDF
Mastering the Master Detail Pattern
PPTX
Presentation - Windows App Development - II - Mr. Chandan Gupta
PDF
Android Jumpstart Jfokus
PDF
Android Support Library: Using ActionBarCompat
PPT
Synapse india mobile apps update
PDF
Designing and implementing_android_uis_for_phones_and_tablets
PPT
Synapse india reviews on i phone and android os
PDF
Android design patterns
From Android to the Mobile Web
Google I/O 2011, Android Honeycomb Highlights
Introduction to Honeycomb APIs - Android Developer Lab 2011 Q3
Android Workshop 2013
01 06 - android programming basics
User interface customization for aem6 circuit
UI Customization in AEM 6.0
Android ui patterns
Android ui patterns
Top Tips for Android UIs - Getting the Magic on Tablets
MOPCON 2014 - Best software architecture in app development
User Interface customization for AEM 6
Mastering the Master Detail Pattern
Presentation - Windows App Development - II - Mr. Chandan Gupta
Android Jumpstart Jfokus
Android Support Library: Using ActionBarCompat
Synapse india mobile apps update
Designing and implementing_android_uis_for_phones_and_tablets
Synapse india reviews on i phone and android os
Android design patterns
Ad

More from CommonsWare (20)

PDF
Gradle and Your Android Wearable Projects
PDF
Getting Android Developers for Your Wearables
PDF
When Microwatts Are Precious: Battery Tips for Wearable Apps
PDF
Android Security: Defending Your Users
PDF
Secondary Screen Support Using DisplayManager
PDF
Not Quite As Painful Threading
PDF
Android Development: The 20,000-Foot View
PDF
Maps V2... And You!
PDF
A Deep Dive Into ViewPager
PDF
Second-Screen Support in Android 4.2
PDF
Integrate Android Apps and Web Apps
PDF
X Means Y
PDF
The Wonderful World of Wearables
PDF
Securing User Data with SQLCipher
PDF
Beaming Data to Devices with NFC
PDF
What's New in Jelly Bean
PDF
Making Money at Mobile: 60 Business Models
PDF
AppsWorld Keynote
PDF
App Integration (Revised and Updated)
PDF
Rich Text Editing and Beyond
Gradle and Your Android Wearable Projects
Getting Android Developers for Your Wearables
When Microwatts Are Precious: Battery Tips for Wearable Apps
Android Security: Defending Your Users
Secondary Screen Support Using DisplayManager
Not Quite As Painful Threading
Android Development: The 20,000-Foot View
Maps V2... And You!
A Deep Dive Into ViewPager
Second-Screen Support in Android 4.2
Integrate Android Apps and Web Apps
X Means Y
The Wonderful World of Wearables
Securing User Data with SQLCipher
Beaming Data to Devices with NFC
What's New in Jelly Bean
Making Money at Mobile: 60 Business Models
AppsWorld Keynote
App Integration (Revised and Updated)
Rich Text Editing and Beyond
Ad

Recently uploaded (20)

PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Cloud computing and distributed systems.
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
A Presentation on Artificial Intelligence
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
cuic standard and advanced reporting.pdf
PDF
Approach and Philosophy of On baking technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation theory and applications.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Machine learning based COVID-19 study performance prediction
Cloud computing and distributed systems.
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence
Diabetes mellitus diagnosis method based random forest with bat algorithm
cuic standard and advanced reporting.pdf
Approach and Philosophy of On baking technology
Understanding_Digital_Forensics_Presentation.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Big Data Technologies - Introduction.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Network Security Unit 5.pdf for BCA BBA.
Advanced methodologies resolving dimensionality complications for autism neur...
Chapter 3 Spatial Domain Image Processing.pdf
Encapsulation_ Review paper, used for researhc scholars
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation theory and applications.pdf

The Action Bar: Front to Back

  • 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