SlideShare uma empresa Scribd logo
1 de 26
Baixar para ler offline
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

Mais conteúdo relacionado

Semelhante a The Action Bar: Front to Back

Google I/O 2011, Android Honeycomb Highlights
Google I/O 2011, Android Honeycomb HighlightsGoogle I/O 2011, Android Honeycomb Highlights
Google I/O 2011, Android Honeycomb Highlights
Romain Guy
 
User interface customization for aem6 circuit
User interface customization for aem6 circuitUser interface customization for aem6 circuit
User interface customization for aem6 circuit
Damien Antipa
 

Semelhante a The Action Bar: Front to Back (20)

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

Mais de CommonsWare

Gradle and Your Android Wearable Projects
Gradle and Your Android Wearable ProjectsGradle and Your Android Wearable Projects
Gradle and Your Android Wearable Projects
CommonsWare
 

Mais de CommonsWare (20)

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

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

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