Wednesday, December 25, 2013

ActionBarSherlock in Android [Latest]

10:33 PM

Implementing ActionBarSherlock in Android
ActionBarSherlock is an library designed to facilitate the use of the action bar design pattern across all versions of Android through a single API.

The library will automatically use the native actionbar implementation on Android 4.0 or later. For previous versions which do not include ActionBar, a custom action bar implementation based on the sources of Ice Cream Sandwich will automatically be wrapped around the layout. This allows to easily develop an application with an action bar for every version of Android from 2.x and up

Step 1: Download the ActionBarSherlock Library from the website http://actionbarsherlock.com/

(I have downloaded ABS from this site : https://api.github.com/repos/JakeWharton/ActionBarSherlock/zipball/4.2.0 )
Step 2: You will get the library in ".zip / .tar" format. After downloading the ABS library, extract it and copy the 'library' folder into your workspace.

Screenshot showing library folder
In case you have downloaded the same ABS as I have, then
Replace the 'android-support-v4' jar file inside the 'libs' folder of 'library' folder in your workspace with the latest 'android-support-v4' jar file from http://actionbarsherlock.com/ .

Step 3: Import the 'library' as a project into Eclipse.

Go to File > Import

Go to Android and select 'Existing Android Code Into Workspace'

Click on 'Browse'

Select the library within your workspace

Make sure 'Copy projects into workspace' is checked and click 'Finish'
Library has been imported



Step 4 : 'Right Click' on 'library' and go to 'Properties'. Make sure 'Is Library' is checked under the field 'Android'.

Clicking on 'Properties' of ' library'


Go to Android and make sure 'Is Library' is checked



Step 5 : Now import ABS library into your project. 'Right Click' on project node and go to your project 'Properties'. Select it and continue with the screen flow.

Click on 'Properties'

Click 'Add'

Select 'library' and click 'OK'

Make sure Is Library is not checked. Click 'Apply' and 'OK'


Step 6 : You might get new error as 'jar mismatch : fix your dependencies'. This error is because the 'android-support-v4' jar file of 'libs' under your project and the 'android-support-v4' jar file of 'libs' under the 'library' is exactly the same. 

So just delete the 'android-support-v4' jar file of 'libs' under your project.

Deleting the jar file of 'libs' under your project 


Step 7: Now go to your project's AndroidManifest file and choose your application theme as android:theme="@style/Theme.Sherlock".

AndroidManifest.xml


Also goto your project's MainActivity.java and extend MainActivity with SherlockActivity.

MainActivity.java




Now you are ready to access ActionBarSherlock Library Features in your Android Application Project.
References

Written by

We are passionate programmers. Enjoying the rich platforms of Semicolon Family of Programming languages we are proud to call ourselves Semicolon Developers.

0 comments:

Post a Comment

 

© 2013 Echo "Semicolon Developers"; Kathmandu. All rights resevered @ Semicolon Developers Network Pvt. Ltd.. Designed by Templateism

Back To Top