SlideShare a Scribd company logo
Using Action Bar
Action Bar
• The action bar is a window feature that identifies the
  application and user location, and provides user actions and
  navigation modes.
• You should use the action bar in most activities that need to
  prominently present user actions or global navigation.
• You can control the behaviors and visibility of the action bar
  with the ActionBar APIs, which were added in Android 3.0 (API
  level 11).
• To use ActionBar in previous Android versions there is a Library
  ‘ActionBarSherlock’ which can be downloaded from
  http://actionbarsherlock.com/
• ActionBarSherlock supports from Android 2.0 and over.
Using ActionBarSherlock(ABS)
  • To use ABS it has to be
    imported in eclipse and
    has to be an opened
    project.
  • Create a new Android
    project in Eclipse.
  • In create project
    window select ‘Create
    project from existing
    source’
  • In the location browse
    to the ‘library folder’ in
    ABS library which was
    downloaded.
Using ActionBarSherlock(ABS)
 • Go to the build path
   window of action bar
   project.
 • Under Libraries tab add
   jar ‘android-support-
   v4.jar’ which is already
   included in the libs
   folder.


 • Also set the build
   target to API 14 or
   higher.
 • Though ABS will be
   used with 2.0 or above
   it requires to be built
   with 4.0 or higher
Using ActionBarSherlock(ABS)
 • Now create a new
   project in Eclipse
   with minimum SDK
   7 and set Build
   target to 15.
Using ActionBarSherlock(ABS)
• Go to the project properties
  again and in the library
  section add the Previous
  created ‘ActionBarSherlock’
  library

• Since the action bar widget is
  very complex it requires a set
  of default themes. The
  library provides three core
  themes—one                  of
  which must be applied to
  each activity on which you
  want the action bar present.
• In the Manifest set theme in
  the appication tag for all
  activities or or under specific
  Activities
• ‘android:theme="@style/Theme.S
  herlock">’
• Now we are ready to integrate
  Action Bar.
• To Enable Action Bar for any
  activity, the Activity must
  extend        ‘SherlockActivity’
  instead of ‘Activity’
• To access ActionBar use
  getSupportActionBar() instead
  of getActionBar().
Adding Menu in ActionBar
• To add menu in ActionBar use menu like
  optionsMenu.
• Define in the XML but Add the tag
  ‘showAsAction’ and set it to ‘ifRoom’
• Now       in   the       Activity’s  onCreateOptionsMenu()         use
     getSupportMenuInflater() to get the menu inflater and inflate the XML
     menu file
• In                the
  onOptionsItemSelect
  ed() do the necessary
  jobs identified menu
  items by ‘id‘ set in
  the XML file
• Here is the result

More Related Content

Viewers also liked (20)

PDF
Lecture 3 getting active through activities
Ahsanul Karim
 
PDF
List Views
Ahsanul Karim
 
PDF
Lecture 1 Session 1 Before Getting Started
Ahsanul Karim
 
PDF
Ui layout (incomplete)
Ahsanul Karim
 
PDF
AndroidManifest
Ahsanul Karim
 
PPTX
Android GPS Tutorial
Ahsanul Karim
 
PPT
Day 6: Android BroadcastReceiver Component
Ahsanul Karim
 
PPTX
Android before getting started
Ahsanul Karim
 
PPTX
Android MapView and MapActivity
Ahsanul Karim
 
PPTX
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Ahsanul Karim
 
PPT
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 
PPTX
Day 9: Make Your App Location Aware using Location API
Ahsanul Karim
 
PPT
Day 4: Android: UI Widgets
Ahsanul Karim
 
PPT
Android User Interface: Basic Form Widgets
Ahsanul Karim
 
PPTX
Android 1.8 sensor
Ahsanul Karim
 
PDF
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
PPTX
Android Services
Ahsanul Karim
 
PDF
Training android
University of Technology
 
PPT
Day 4: Android: Getting Active through Activities
Ahsanul Karim
 
PDF
Day 2 android internals a quick overview
Ahsanul Karim
 
Lecture 3 getting active through activities
Ahsanul Karim
 
List Views
Ahsanul Karim
 
Lecture 1 Session 1 Before Getting Started
Ahsanul Karim
 
Ui layout (incomplete)
Ahsanul Karim
 
AndroidManifest
Ahsanul Karim
 
Android GPS Tutorial
Ahsanul Karim
 
Day 6: Android BroadcastReceiver Component
Ahsanul Karim
 
Android before getting started
Ahsanul Karim
 
Android MapView and MapActivity
Ahsanul Karim
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Ahsanul Karim
 
Day 5: Android User Interface [View Widgets]
Ahsanul Karim
 
Day 9: Make Your App Location Aware using Location API
Ahsanul Karim
 
Day 4: Android: UI Widgets
Ahsanul Karim
 
Android User Interface: Basic Form Widgets
Ahsanul Karim
 
Android 1.8 sensor
Ahsanul Karim
 
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
Android Services
Ahsanul Karim
 
Training android
University of Technology
 
Day 4: Android: Getting Active through Activities
Ahsanul Karim
 
Day 2 android internals a quick overview
Ahsanul Karim
 

Similar to Action Bar Sherlock tutorial (20)

PPTX
Action bar & ActionBarSherlock
Zahid Ali Shah
 
PDF
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
Kobkrit Viriyayudhakorn
 
PPTX
Chapter 2 lesson-1 adding the action bar
Kalluri Vinay Reddy
 
TXT
Readme
Rizwan Siddiquee
 
PDF
Material Theme
Anuchit Chalothorn
 
PDF
WebObjects Developer Tools
WO Community
 
PPTX
Chapter 2 lesson-2 styling the action bar
Kalluri Vinay Reddy
 
PDF
Ember vs Backbone
Abdriy Mosin
 
PPTX
ActionBarCompat Tutorial-Part 1(Prepare and Setup)
Haining Lee
 
PDF
Beginning to iPhone development
Vonbo
 
PDF
iPhone dev intro
Vonbo
 
PDF
What's new in android: jetpack compose 2024
Toru Wonyoung Choi
 
PDF
The Synergy of Drupal Hooks/APIs (Custom Module Development with ChartJS)
Ranel Padon
 
PDF
Android Support Library: Using ActionBarCompat
cbeyls
 
PPTX
Unit 2 - Object Navigator, Repository and ABAP Programs
dubon07
 
PDF
Android intents-3 www.j2program.blogspot.com
Mohamed Rimzan
 
PPTX
Make Mobile Apps Quickly
Gil Irizarry
 
PDF
td_mxc_rubyrails_shin
tutorialsruby
 
PDF
td_mxc_rubyrails_shin
tutorialsruby
 
PDF
Appear IQ - Tutorials Backbone.js
Appear
 
Action bar & ActionBarSherlock
Zahid Ali Shah
 
[React-Native Tutorial 10] Camera Roll / Gallery / Camera / Native Modules by...
Kobkrit Viriyayudhakorn
 
Chapter 2 lesson-1 adding the action bar
Kalluri Vinay Reddy
 
Material Theme
Anuchit Chalothorn
 
WebObjects Developer Tools
WO Community
 
Chapter 2 lesson-2 styling the action bar
Kalluri Vinay Reddy
 
Ember vs Backbone
Abdriy Mosin
 
ActionBarCompat Tutorial-Part 1(Prepare and Setup)
Haining Lee
 
Beginning to iPhone development
Vonbo
 
iPhone dev intro
Vonbo
 
What's new in android: jetpack compose 2024
Toru Wonyoung Choi
 
The Synergy of Drupal Hooks/APIs (Custom Module Development with ChartJS)
Ranel Padon
 
Android Support Library: Using ActionBarCompat
cbeyls
 
Unit 2 - Object Navigator, Repository and ABAP Programs
dubon07
 
Android intents-3 www.j2program.blogspot.com
Mohamed Rimzan
 
Make Mobile Apps Quickly
Gil Irizarry
 
td_mxc_rubyrails_shin
tutorialsruby
 
td_mxc_rubyrails_shin
tutorialsruby
 
Appear IQ - Tutorials Backbone.js
Appear
 
Ad

More from Ahsanul Karim (16)

PDF
Lecture 5: Storage: Saving Data Database, Files & Preferences
Ahsanul Karim
 
PDF
Lecture 2(b) Android Internals A Quick Overview
Ahsanul Karim
 
PDF
লেকচার ১ (ক)- শুরুর আগে:
Ahsanul Karim
 
PPTX
Day 15: Content Provider: Using Contacts API
Ahsanul Karim
 
PPTX
Day 15: Working in Background
Ahsanul Karim
 
PDF
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
DOC
Day 4: Activity lifecycle
Ahsanul Karim
 
PDF
Day 1 Android: Before Getting Started
Ahsanul Karim
 
PDF
Mobile Banking in Bangladesh: An Incomplete Study
Ahsanul Karim
 
PDF
GCM for Android
Ahsanul Karim
 
PDF
Sensors in Android (old)
Ahsanul Karim
 
PDF
Day1 before getting_started
Ahsanul Karim
 
PPTX
Android Workshop: Day 1 Part 3
Ahsanul Karim
 
PPTX
Android Workshop Day 1 Part 2
Ahsanul Karim
 
PPTX
Introduction to Android Development: Before Getting Started
Ahsanul Karim
 
PPTX
Client-Server
Ahsanul Karim
 
Lecture 5: Storage: Saving Data Database, Files & Preferences
Ahsanul Karim
 
Lecture 2(b) Android Internals A Quick Overview
Ahsanul Karim
 
লেকচার ১ (ক)- শুরুর আগে:
Ahsanul Karim
 
Day 15: Content Provider: Using Contacts API
Ahsanul Karim
 
Day 15: Working in Background
Ahsanul Karim
 
Day 8: Dealing with Lists and ListViews
Ahsanul Karim
 
Day 4: Activity lifecycle
Ahsanul Karim
 
Day 1 Android: Before Getting Started
Ahsanul Karim
 
Mobile Banking in Bangladesh: An Incomplete Study
Ahsanul Karim
 
GCM for Android
Ahsanul Karim
 
Sensors in Android (old)
Ahsanul Karim
 
Day1 before getting_started
Ahsanul Karim
 
Android Workshop: Day 1 Part 3
Ahsanul Karim
 
Android Workshop Day 1 Part 2
Ahsanul Karim
 
Introduction to Android Development: Before Getting Started
Ahsanul Karim
 
Client-Server
Ahsanul Karim
 
Ad

Recently uploaded (20)

PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Digital Circuits, important subject in CS
contactparinay1
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 

Action Bar Sherlock tutorial

  • 2. Action Bar • The action bar is a window feature that identifies the application and user location, and provides user actions and navigation modes. • You should use the action bar in most activities that need to prominently present user actions or global navigation. • You can control the behaviors and visibility of the action bar with the ActionBar APIs, which were added in Android 3.0 (API level 11). • To use ActionBar in previous Android versions there is a Library ‘ActionBarSherlock’ which can be downloaded from http://actionbarsherlock.com/ • ActionBarSherlock supports from Android 2.0 and over.
  • 3. Using ActionBarSherlock(ABS) • To use ABS it has to be imported in eclipse and has to be an opened project. • Create a new Android project in Eclipse. • In create project window select ‘Create project from existing source’ • In the location browse to the ‘library folder’ in ABS library which was downloaded.
  • 4. Using ActionBarSherlock(ABS) • Go to the build path window of action bar project. • Under Libraries tab add jar ‘android-support- v4.jar’ which is already included in the libs folder. • Also set the build target to API 14 or higher. • Though ABS will be used with 2.0 or above it requires to be built with 4.0 or higher
  • 5. Using ActionBarSherlock(ABS) • Now create a new project in Eclipse with minimum SDK 7 and set Build target to 15.
  • 6. Using ActionBarSherlock(ABS) • Go to the project properties again and in the library section add the Previous created ‘ActionBarSherlock’ library • Since the action bar widget is very complex it requires a set of default themes. The library provides three core themes—one of which must be applied to each activity on which you want the action bar present. • In the Manifest set theme in the appication tag for all activities or or under specific Activities • ‘android:theme="@style/Theme.S herlock">’
  • 7. • Now we are ready to integrate Action Bar. • To Enable Action Bar for any activity, the Activity must extend ‘SherlockActivity’ instead of ‘Activity’ • To access ActionBar use getSupportActionBar() instead of getActionBar().
  • 8. Adding Menu in ActionBar • To add menu in ActionBar use menu like optionsMenu. • Define in the XML but Add the tag ‘showAsAction’ and set it to ‘ifRoom’
  • 9. • Now in the Activity’s onCreateOptionsMenu() use getSupportMenuInflater() to get the menu inflater and inflate the XML menu file • In the onOptionsItemSelect ed() do the necessary jobs identified menu items by ‘id‘ set in the XML file
  • 10. • Here is the result