Android Working With ActionBarSherlock Basics


In the previous post  we seen an Action bar that could be implemented on Honeycomb (API Level 11).But what about other other level for that  a libraray called ActionBarshelock was introduced.
ActionBarSherlock is a library by Jake Wharton, that enables you to use action bars even on older devices without having to code an action bar from scratch. This library deals with all the details you do not want to care about. Even Googlers like Roman Nurik (visit to see what he says here) recommend to use this library and the Google IO app also makes use of this lib. So should you!

Some Intersting note:
"According to Androlyzer, Whatsapp uses ActionBarSherlock for their Action Bar, which allows them to have a consistent Action Bar on all Android 2.1+ devices."

http://androidgreeve.blogspot.in/p/blog-page.html

With this post I start my series about the action bar by simply adding an action bar to the project of my last post, adding some action items to it and explaining some basics of action bars. The focus of this post is mainly on getting ActionBarSherlock to run on your project. As such it is an introductory post about the action bar.
Since the action bar offers many functions and is the most important navigational component.

So,Lets start it:

Where to get ActionBarSherlock ?How to Add ActionBarSherlock to  Android sdk in eclipse?
Adding ActionBarSherlock to eclipse
Step 1:
First we need to download the library to do this  [download the library from actionbarsherlock.com.]
After this unzip/untar it

What does this contains?
The download contains three folders: library, samples and website.
The samples folder contains four sample projects to showcase what you can do and to show you how to do it. You should have a look at them.
The website folder contains the code of the project website.
The library folder finally contains ActionBarSherlock’s source code.

Step 2:
Go to Eclipse and add the ABS-library as an Android project.
//Do not use Eclipse’s import tool to import the ActionBarSherlock library – it would not work immediately and you would have to fix some settings.  
Instead use the project creation wizard of the Android Developer Tools.
Open File -> New -> Project -> Android Project From Existing Code.

http://d3a0c3fa3t59bz.cloudfront.net/wordpress/wp-content/uploads/2012/12/import_abs_project.png

Step 3:
select the folder, which Eclipse then uses to search for projects. 

Step 4:
If you select the ActionBarSherlock root folder, Eclipse suggests a list of projects to create. Leave the “library” project checked and uncheck all others:
http://d3a0c3fa3t59bz.cloudfront.net/wordpress/wp-content/uploads/2012/12/selecting_library_project.png

Click “Finish” to create the project.
Eclipse will now create a new project named “library”. I prefer a more useful name, so select the project called “library” and hit F2 to rename the project. I have renamed the project in Eclipse to “ActionBarSherlock”, so all following screens will refer to this name.

So this done adding the library to Eclipse.

Now we need to Add ActionBarSherlock to your project

http://d3a0c3fa3t59bz.cloudfront.net/wordpress/wp-content/uploads/2012/12/adding_library_to_project.png

Now that ABS is a library project you have to tell your own project to use it. I will use the project of my last post for this. Go to  project settings and switch to the Android tab .
If necessary scroll down until you see the Library panel. Click “Add”.
In the next window all available library projects will be listed. Select ActionBarSherlock and click “Ok”.

http://d3a0c3fa3t59bz.cloudfront.net/wordpress/wp-content/uploads/2012/12/selecting_library.png

When the window disappears the library should be listed in the library panel of the Android properties tab:
http://d3a0c3fa3t59bz.cloudfront.net/wordpress/wp-content/uploads/2012/12/check_if_all_is_good.png

 Tip:
Android Developer Tools do not use the name of a project to reference it, but instead point to the directory itself. And what’s even more annoying is that a symlink gets translated to its real path, which is bound to change more often than a symlink.

 Should you ever want to change the directory, you have to delete the reference to the library with the old path and link to the newly imported library. But unless you do a fresh install for blog posts, this probably won’t happen too often

That’s it.Your project bundles the lib from now on.

Whats Next?
Just adding the library won’t magically add an action bar to your project. Instead you have to change some of your code Android Working With ActionBarSherlock We will see how our previous Swipeable tabs can be made using ActionBarSherlock  .


Alll the world is a laboratory to the inquiring mind! Join Us

Comments

Alexfollows said…
Amazing! thats what i looking for nicely written
Alexfollows said…
Well man i thougth this post would be your next post nice and congrats for 1K
Alexfollows said…
NIce And Awesome.......man
Alexfollows said…
Your Posters looks Great very well explained thanks man
Alexfollows said…
very Nice tutorial

Popular posts from this blog

Android Navigation Drawer sliding menu with fragments

8 Effective plots with Matplotlib and Pandas Dataframe

Step by Step Guide to Setup Android 5.0 Lollipop Sdk in Eclipse