SlideShare a Scribd company logo
ActionBarCompat Tutorial
Part 1-Prepare and Setup
http://www.mobiletuts.me
Mobiletuts.me@gmail.com
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Action Bar
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
The action bar is a window feature that
identifies the user location, and provides user
actions and navigation modes. Using the action
bar offers your users a familiar interface across
applications that the system gracefully adapts
for different screen configurations.
Figure 1. An action bar that includes the [1] app icon, [2]
two action items, and [3] action overflow.
The action bar provides several key functions:
Provides a dedicated space for giving your app an identity and indicating the user's
location in the app.
Makes important actions prominent and accessible in a predictable way (such as
Search).
Supports consistent navigation and view switching within apps (with tabs or drop-
down lists).
ActionBarActivity or Activity?
If you want to set title , logo, navigation modes for an ActionBar, you need to get a reference to
ActionBar.
With sdk level higher than 11 (>=11), you can directly call getActionBar() in an Activity to fetch a
reference of ActionBar which you can configure.
For sdk level lower than 11 (<=10), however, getActionBar is not supported in an Activity.
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
ActionBarActivity or Activity?
Google Android team released a new backward-compatible Action Bar
implementation called ActionBarCompat that‘s part of the Support Library r18 during
I/O 2013 . The ActionBarCompat APIs let you build the essential Action Bar design
pattern into your app, with broad compatibility back to Android 2.1 (sdk7).
ActionBarActivity (android.support.v7.app.ActionBarActivity) and ActionBar
(android.support.v7.app.ActionBar) was introduced within ActionBarCompat, which
can be used essentially as same as Activity with ActionBar features in sdk levels higher
than 11.
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
ActionBarActivity for Backward Compatibility
Therefore use ActionBarActivity if you need to use ActionBar while supporting sdk
level lower than 11.
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Get Started with ActionBarCompat
ActionBarCompat is a new API in the Android Support Library that allows you to add
an Action Bar to applications targeting minSdkVersion 7 or greater. The API and
integration have been designed to closely mirror the existing framework APIs, giving
you an easy migration path for your existing apps.
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Add ActionBarCompat as a project dependency
1. Android Studio or Eclipse+ADT go to Tools->Android->SDK Manager
2. Check if the Android Support Library (revision 18) has been installed.
The version of Android support library ( Revision 18 ) is released with a new library called appcompat
under the package android.support.v7.The new library facilitates users to implement action bar back
up to Android 2.1 ( API Level 7 ) .
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Adding ActionBarCompat support library
Eclipse
Make sure you have downloaded the Android Support Library using the SDK Manager.
Create a libs/ directory in the root of your application project.
Copy the JAR files from your Android SDK installation directory
/extras/android/support/v7/appcompat/libs/android-support-v4.jar
/extras/android/support/v7/appcompat/libs/android-support-v7-appcompat.jar
into your application's project libs/ directory.
Right click the JAR file and select Build Path > Add to Build Path.
Android Studio
Make sure you have downloaded the Android Support Repository using the SDK Manager.
Open the build.gradle file for your application.
Add the support library to the dependencies section. For example, to add the v7 appcompat
library, add the following lines:
dependencies {
…
compile 'com.android.support:appcompat-v7:18.0.0'
}
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Create New Android Project
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Create New Android Project
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Dependency
The Gradle build script dependency identifier for this library is as follows:
com.android.support:appcompat-v7:18.0.0+
This dependency notation specifies the release version 18.0.0 or higher.
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
When using default Activity
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Default Activity support ActionBar on level higher
than API 11
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Running on API17
Use ActionBarActivity for Backward Compatibility
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Using ActionBarActivity instead of
Activity
Done? Not yet, if you compile and run now, you will run into fata error caused
by theme setting.
Error Caused by Theme Setting
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
This is cause by theme setting. When using ActionBarCompat, you can only use a
Theme.AppCompat theme or its descendant (for customized theme).
Update Style Resources
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
The first things to update are your Activity themes so they use a Theme.AppCompat
theme. If you're currently using one of the Theme.Holo themes then just replace this
with the related Theme.AppCompat theme. For instance if you have the following in
your AndroidManifest.xml:
<activity
...
android:theme="@android:style/Theme.Holo" />
You would change it to:
<activity
...
android:theme="@style/Theme.AppCompat" />
UseTheme.AppCompat theme or its descendant
Update Style Resources
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
UseTheme.AppCompat theme or its descendant
If you don’t want to change your activities’ theme setting one by one, you can
change the theme setting for application in AndroidManifest.xml:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<!-- Application theme. Which is a decendant of Theme.App -->
<style name="AppTheme" parent="AppBaseTheme">
</style>
Becareful with values-v11/14
When you update the style resource files, do update all the styles.xml in values folder
and the possible values-v11 and values-v14 folder. Cause your app may load styles.xml
file in values-v1X folder according to target Android API level!
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Try again, it works now!
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Running on API17
Add More Actions on Action Bar
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
In the following sections, I will show how to add
Actions such as Search to Action Bar.
You can download these icons which you can use
for Actions from Download the Action Bar Icon
Pack
Then copy the icons you need to drawable
folders. Here I copied 2_action_search.png files
to drawable-hdpi, drawable-xhdpi and drawable-
mdpi folders.
Structure of Action Bar Icon Pack
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Modify Menu Resources
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
As with the standard Action Bar in Android 3.0 and later versions, action items are
added via the options menu. The difference with ActionBarCompat is that you need to
modify your Menu resource files so that any action item attributes come from
ActionBarCompat's XML namespace.
Now, you did it.
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
Compile and run again.
Running on API 17
Running on API 7
To be continued
• In next tutorial, I will show you how to
1. Configure menu items;
2. Add menu items callback (how to interact
with user through Action Bar);
3. Something else 
10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com

More Related Content

What's hot

Mule Integration with Atlassian JIRA
Mule Integration with Atlassian JIRAMule Integration with Atlassian JIRA
Mule Integration with Atlassian JIRA
Ramakrishna Narkedamilli
 
What are The Top Features of Angular 7?
What are The Top Features of Angular 7?What are The Top Features of Angular 7?
What are The Top Features of Angular 7?
NCode Technologies, Inc.
 
Android Widget
Android WidgetAndroid Widget
Android Widget
ELLURU Kalyan
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
Vivek chan
 
How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react
MoonTechnolabsPvtLtd
 
Rest With Raml
Rest With RamlRest With Raml
Rest With Raml
vijay dhanakodi
 
Write Your iOS App in Swift with a Graph Database
Write Your iOS App in Swift with a Graph DatabaseWrite Your iOS App in Swift with a Graph Database
Write Your iOS App in Swift with a Graph Database
Anthony Blatner
 
GDG Oslo: Hidden Android features
GDG Oslo: Hidden Android featuresGDG Oslo: Hidden Android features
GDG Oslo: Hidden Android features
Konstantin Loginov
 
Python Ireland Nov 2009 Talk - Appengine
Python Ireland Nov 2009 Talk - AppenginePython Ireland Nov 2009 Talk - Appengine
Python Ireland Nov 2009 Talk - Appengine
Python Ireland
 
Anypoint platform for API's glossary
Anypoint platform for API's glossaryAnypoint platform for API's glossary
Anypoint platform for API's glossary
Achyuta Lakshmi
 
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Suzzicks
 
Google Firebase
Google FirebaseGoogle Firebase
Google Firebase
Mukul parmar
 
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
Alex Ershov
 
6 Reasons Why You Should Create React Native Apps For Your Enterprise in 2021
6 Reasons Why You Should Create React Native Apps For Your Enterprise in 20216 Reasons Why You Should Create React Native Apps For Your Enterprise in 2021
6 Reasons Why You Should Create React Native Apps For Your Enterprise in 2021
Claritus Consulting
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
Vivek chan
 
Managing Mobile Apps: A PhoneGap Enterprise Introduction for Marketers
Managing Mobile Apps: A PhoneGap Enterprise Introduction for MarketersManaging Mobile Apps: A PhoneGap Enterprise Introduction for Marketers
Managing Mobile Apps: A PhoneGap Enterprise Introduction for Marketers
arumsey
 
EVOLVE'14 | Enhance | John Fait | Add Analytics To Your AEM Apps
EVOLVE'14 | Enhance | John Fait | Add Analytics To Your AEM AppsEVOLVE'14 | Enhance | John Fait | Add Analytics To Your AEM Apps
EVOLVE'14 | Enhance | John Fait | Add Analytics To Your AEM Apps
Evolve The Adobe Digital Marketing Community
 
Summit 2015: Mobile App Dev and Content Management with Adobe Experience Manager
Summit 2015: Mobile App Dev and Content Management with Adobe Experience ManagerSummit 2015: Mobile App Dev and Content Management with Adobe Experience Manager
Summit 2015: Mobile App Dev and Content Management with Adobe Experience Manager
brucelefebvre
 
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Andy Maleh
 

What's hot (19)

Mule Integration with Atlassian JIRA
Mule Integration with Atlassian JIRAMule Integration with Atlassian JIRA
Mule Integration with Atlassian JIRA
 
What are The Top Features of Angular 7?
What are The Top Features of Angular 7?What are The Top Features of Angular 7?
What are The Top Features of Angular 7?
 
Android Widget
Android WidgetAndroid Widget
Android Widget
 
03 asp.net session04
03 asp.net session0403 asp.net session04
03 asp.net session04
 
How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react
 
Rest With Raml
Rest With RamlRest With Raml
Rest With Raml
 
Write Your iOS App in Swift with a Graph Database
Write Your iOS App in Swift with a Graph DatabaseWrite Your iOS App in Swift with a Graph Database
Write Your iOS App in Swift with a Graph Database
 
GDG Oslo: Hidden Android features
GDG Oslo: Hidden Android featuresGDG Oslo: Hidden Android features
GDG Oslo: Hidden Android features
 
Python Ireland Nov 2009 Talk - Appengine
Python Ireland Nov 2009 Talk - AppenginePython Ireland Nov 2009 Talk - Appengine
Python Ireland Nov 2009 Talk - Appengine
 
Anypoint platform for API's glossary
Anypoint platform for API's glossaryAnypoint platform for API's glossary
Anypoint platform for API's glossary
 
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
 
Google Firebase
Google FirebaseGoogle Firebase
Google Firebase
 
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
 
6 Reasons Why You Should Create React Native Apps For Your Enterprise in 2021
6 Reasons Why You Should Create React Native Apps For Your Enterprise in 20216 Reasons Why You Should Create React Native Apps For Your Enterprise in 2021
6 Reasons Why You Should Create React Native Apps For Your Enterprise in 2021
 
12 asp.net session17
12 asp.net session1712 asp.net session17
12 asp.net session17
 
Managing Mobile Apps: A PhoneGap Enterprise Introduction for Marketers
Managing Mobile Apps: A PhoneGap Enterprise Introduction for MarketersManaging Mobile Apps: A PhoneGap Enterprise Introduction for Marketers
Managing Mobile Apps: A PhoneGap Enterprise Introduction for Marketers
 
EVOLVE'14 | Enhance | John Fait | Add Analytics To Your AEM Apps
EVOLVE'14 | Enhance | John Fait | Add Analytics To Your AEM AppsEVOLVE'14 | Enhance | John Fait | Add Analytics To Your AEM Apps
EVOLVE'14 | Enhance | John Fait | Add Analytics To Your AEM Apps
 
Summit 2015: Mobile App Dev and Content Management with Adobe Experience Manager
Summit 2015: Mobile App Dev and Content Management with Adobe Experience ManagerSummit 2015: Mobile App Dev and Content Management with Adobe Experience Manager
Summit 2015: Mobile App Dev and Content Management with Adobe Experience Manager
 
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
 

Similar to ActionBarCompat Tutorial-Part 1(Prepare and Setup)

Chapter 2 lesson-1 adding the action bar
Chapter 2 lesson-1 adding the action barChapter 2 lesson-1 adding the action bar
Chapter 2 lesson-1 adding the action bar
Kalluri Vinay Reddy
 
Android ui with xml
Android ui with xmlAndroid ui with xml
Android ui with xml
Egerton University
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
Gil Irizarry
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
Prajakta Dharmpurikar
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
Roy Clarkson
 
ANGULAR JS LAB MANUAL(final) vtu2021 sch
ANGULAR JS LAB MANUAL(final) vtu2021 schANGULAR JS LAB MANUAL(final) vtu2021 sch
ANGULAR JS LAB MANUAL(final) vtu2021 sch
kannikadg
 
Android Development project
Android Development projectAndroid Development project
Android Development project
Minhaj Kazi
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
Vivek Bhusal
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
Chandrakant Divate
 
Compose camp 4.pptx
Compose camp 4.pptxCompose camp 4.pptx
Compose camp 4.pptx
bcedsc
 
Quickly Build a Native Mobile App for Your Community Using Salesforce Mobile SDK
Quickly Build a Native Mobile App for Your Community Using Salesforce Mobile SDKQuickly Build a Native Mobile App for Your Community Using Salesforce Mobile SDK
Quickly Build a Native Mobile App for Your Community Using Salesforce Mobile SDK
Salesforce Developers
 
Quickly Build a Native Mobile App for your Community using Salesforce Mobile SDK
Quickly Build a Native Mobile App for your Community using Salesforce Mobile SDKQuickly Build a Native Mobile App for your Community using Salesforce Mobile SDK
Quickly Build a Native Mobile App for your Community using Salesforce Mobile SDK
Michael Welburn
 
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
MobileMoxie
 
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
DicodingEvent
 
Migrating JavaME Apps to Android
Migrating JavaME Apps to AndroidMigrating JavaME Apps to Android
Migrating JavaME Apps to Android
Motorola Mobility - MOTODEV
 
Lecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile AppsLecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile Apps
Maksym Davydov
 
Getting started with android programming
Getting started with android programmingGetting started with android programming
Getting started with android programming
PERKYTORIALS
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
Chiew Carol
 
Beginning android
Beginning android Beginning android
Beginning android
Igor R
 
How to Build a Hybrid App: A Detailed Outline
How to Build a Hybrid App: A Detailed Outline How to Build a Hybrid App: A Detailed Outline
How to Build a Hybrid App: A Detailed Outline
WebGuru Infosystems Pvt. Ltd.
 

Similar to ActionBarCompat Tutorial-Part 1(Prepare and Setup) (20)

Chapter 2 lesson-1 adding the action bar
Chapter 2 lesson-1 adding the action barChapter 2 lesson-1 adding the action bar
Chapter 2 lesson-1 adding the action bar
 
Android ui with xml
Android ui with xmlAndroid ui with xml
Android ui with xml
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
ANGULAR JS LAB MANUAL(final) vtu2021 sch
ANGULAR JS LAB MANUAL(final) vtu2021 schANGULAR JS LAB MANUAL(final) vtu2021 sch
ANGULAR JS LAB MANUAL(final) vtu2021 sch
 
Android Development project
Android Development projectAndroid Development project
Android Development project
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 
Mobile Application Development-Components and Layouts
Mobile Application Development-Components and LayoutsMobile Application Development-Components and Layouts
Mobile Application Development-Components and Layouts
 
Compose camp 4.pptx
Compose camp 4.pptxCompose camp 4.pptx
Compose camp 4.pptx
 
Quickly Build a Native Mobile App for Your Community Using Salesforce Mobile SDK
Quickly Build a Native Mobile App for Your Community Using Salesforce Mobile SDKQuickly Build a Native Mobile App for Your Community Using Salesforce Mobile SDK
Quickly Build a Native Mobile App for Your Community Using Salesforce Mobile SDK
 
Quickly Build a Native Mobile App for your Community using Salesforce Mobile SDK
Quickly Build a Native Mobile App for your Community using Salesforce Mobile SDKQuickly Build a Native Mobile App for your Community using Salesforce Mobile SDK
Quickly Build a Native Mobile App for your Community using Salesforce Mobile SDK
 
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
Life After Mobilegeddon: App Deep Linking Strategies - Pubcon October 2015
 
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
Baparekraf Digital Talent Day: Monitoring dan Coaching Penerima Fasilitasi BD...
 
Migrating JavaME Apps to Android
Migrating JavaME Apps to AndroidMigrating JavaME Apps to Android
Migrating JavaME Apps to Android
 
Lecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile AppsLecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile Apps
 
Getting started with android programming
Getting started with android programmingGetting started with android programming
Getting started with android programming
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
Beginning android
Beginning android Beginning android
Beginning android
 
How to Build a Hybrid App: A Detailed Outline
How to Build a Hybrid App: A Detailed Outline How to Build a Hybrid App: A Detailed Outline
How to Build a Hybrid App: A Detailed Outline
 

Recently uploaded

Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 

Recently uploaded (20)

Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 

ActionBarCompat Tutorial-Part 1(Prepare and Setup)

  • 1. ActionBarCompat Tutorial Part 1-Prepare and Setup http://www.mobiletuts.me Mobiletuts.me@gmail.com 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 2. Action Bar 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com The action bar is a window feature that identifies the user location, and provides user actions and navigation modes. Using the action bar offers your users a familiar interface across applications that the system gracefully adapts for different screen configurations. Figure 1. An action bar that includes the [1] app icon, [2] two action items, and [3] action overflow. The action bar provides several key functions: Provides a dedicated space for giving your app an identity and indicating the user's location in the app. Makes important actions prominent and accessible in a predictable way (such as Search). Supports consistent navigation and view switching within apps (with tabs or drop- down lists).
  • 3. ActionBarActivity or Activity? If you want to set title , logo, navigation modes for an ActionBar, you need to get a reference to ActionBar. With sdk level higher than 11 (>=11), you can directly call getActionBar() in an Activity to fetch a reference of ActionBar which you can configure. For sdk level lower than 11 (<=10), however, getActionBar is not supported in an Activity. 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 4. ActionBarActivity or Activity? Google Android team released a new backward-compatible Action Bar implementation called ActionBarCompat that‘s part of the Support Library r18 during I/O 2013 . The ActionBarCompat APIs let you build the essential Action Bar design pattern into your app, with broad compatibility back to Android 2.1 (sdk7). ActionBarActivity (android.support.v7.app.ActionBarActivity) and ActionBar (android.support.v7.app.ActionBar) was introduced within ActionBarCompat, which can be used essentially as same as Activity with ActionBar features in sdk levels higher than 11. 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 5. ActionBarActivity for Backward Compatibility Therefore use ActionBarActivity if you need to use ActionBar while supporting sdk level lower than 11. 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 6. Get Started with ActionBarCompat ActionBarCompat is a new API in the Android Support Library that allows you to add an Action Bar to applications targeting minSdkVersion 7 or greater. The API and integration have been designed to closely mirror the existing framework APIs, giving you an easy migration path for your existing apps. 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 7. Add ActionBarCompat as a project dependency 1. Android Studio or Eclipse+ADT go to Tools->Android->SDK Manager 2. Check if the Android Support Library (revision 18) has been installed. The version of Android support library ( Revision 18 ) is released with a new library called appcompat under the package android.support.v7.The new library facilitates users to implement action bar back up to Android 2.1 ( API Level 7 ) . 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 8. Adding ActionBarCompat support library Eclipse Make sure you have downloaded the Android Support Library using the SDK Manager. Create a libs/ directory in the root of your application project. Copy the JAR files from your Android SDK installation directory /extras/android/support/v7/appcompat/libs/android-support-v4.jar /extras/android/support/v7/appcompat/libs/android-support-v7-appcompat.jar into your application's project libs/ directory. Right click the JAR file and select Build Path > Add to Build Path. Android Studio Make sure you have downloaded the Android Support Repository using the SDK Manager. Open the build.gradle file for your application. Add the support library to the dependencies section. For example, to add the v7 appcompat library, add the following lines: dependencies { … compile 'com.android.support:appcompat-v7:18.0.0' } 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 9. Create New Android Project 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 10. Create New Android Project 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 11. Dependency The Gradle build script dependency identifier for this library is as follows: com.android.support:appcompat-v7:18.0.0+ This dependency notation specifies the release version 18.0.0 or higher. 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 12. When using default Activity 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 13. Default Activity support ActionBar on level higher than API 11 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com Running on API17
  • 14. Use ActionBarActivity for Backward Compatibility 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com Using ActionBarActivity instead of Activity Done? Not yet, if you compile and run now, you will run into fata error caused by theme setting.
  • 15. Error Caused by Theme Setting 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com This is cause by theme setting. When using ActionBarCompat, you can only use a Theme.AppCompat theme or its descendant (for customized theme).
  • 16. Update Style Resources 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com The first things to update are your Activity themes so they use a Theme.AppCompat theme. If you're currently using one of the Theme.Holo themes then just replace this with the related Theme.AppCompat theme. For instance if you have the following in your AndroidManifest.xml: <activity ... android:theme="@android:style/Theme.Holo" /> You would change it to: <activity ... android:theme="@style/Theme.AppCompat" /> UseTheme.AppCompat theme or its descendant
  • 17. Update Style Resources 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com UseTheme.AppCompat theme or its descendant If you don’t want to change your activities’ theme setting one by one, you can change the theme setting for application in AndroidManifest.xml: <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <style name="AppBaseTheme" parent="android:Theme.Light"> </style> <!-- Application theme. Which is a decendant of Theme.App --> <style name="AppTheme" parent="AppBaseTheme"> </style>
  • 18. Becareful with values-v11/14 When you update the style resource files, do update all the styles.xml in values folder and the possible values-v11 and values-v14 folder. Cause your app may load styles.xml file in values-v1X folder according to target Android API level! 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 19. Try again, it works now! 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com Running on API17
  • 20. Add More Actions on Action Bar 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com In the following sections, I will show how to add Actions such as Search to Action Bar. You can download these icons which you can use for Actions from Download the Action Bar Icon Pack Then copy the icons you need to drawable folders. Here I copied 2_action_search.png files to drawable-hdpi, drawable-xhdpi and drawable- mdpi folders.
  • 21. Structure of Action Bar Icon Pack 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com
  • 22. Modify Menu Resources 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com As with the standard Action Bar in Android 3.0 and later versions, action items are added via the options menu. The difference with ActionBarCompat is that you need to modify your Menu resource files so that any action item attributes come from ActionBarCompat's XML namespace.
  • 23. Now, you did it. 10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com Compile and run again. Running on API 17 Running on API 7
  • 24. To be continued • In next tutorial, I will show you how to 1. Configure menu items; 2. Add menu items callback (how to interact with user through Action Bar); 3. Something else  10/10/2013 Mobiletuts.me mobiletuts.me@gmail.com