when to use Action bar and sherlockActionbar [closed] - android

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i am newbie in Android and in this forum too. i don't know when to use Action bar and sherlockActionbar. i am using Api 16 . Can someone please explain here? Thanks in advance.
Updated :please tell me how to customize my Action bar. i don't wanna show my app icon in left side of action bar and also want s to change the color and put the image over there??

Action bar is build for API Level 11 or higher so that will not run below that API version.
Note:
This class is included in the support library for compatibility with API level 7 and higher. If you're developing your app for API level 11 and higher only, you should instead use the framework ActionBar class.
ActionBar Support Lib / ActionBarCompat That has released by Google for older version also.
We released a new backward-compatible Action Bar implementation called ActionBarCompat that's part of the Support Library r18. The ActionBarCompat APIs let you build the essential Action Bar design pattern into your app, with broad compatibility back to Android 2.1.
ActionbarSherlock is library project which support in lower version. Minimum API level is 7
In your case,
If your android:minSDK="16" then you should go with ActionBar. but ,
If you want to set your android:minSDK="10" or below then that , in that case you should use ActionbarSherlock.

For sherlockActionbar, you should build your application with SDK version 14 or above.
Due to its use of the native action bar and its related classes on Ice
Cream Sandwich, the library requires that both it and your project are
compiled with Android 4.0 or newer. The project also requires that you
are compiling with JDK 1.6 in both your editor and any build systems
that you may be using.
And if you check out the support library at:
http://developer.android.com/tools/support-library/index.html
If you are using Support Library v7 or above:
New v7 appcompat library:
Added ActionBar to allow implementation of the action bar user interface design pattern back to Android 2.1 (API level 7) and higher. Use of this class requires that you implement your activity by extending the new ActionBarActivity class.
It is built in with Action Bar and you can use it safely without externally including SherlockActionBar.
Note: v7 appcompat library depends on the v4 Support Library. If you are using
Ant or Eclipse, make sure you include the v4 Support Library as part
of this library's classpath.
Of course you have to use Sherlock if you are still using v4 support library solely.

Answer for your updated question:
If you want to remove app icon from action bar then just remove this line from Manifest file in application tag
android:icon="#drawable/app_icon"
If you wanna change that image just put one image in drawable folder and replace app_icon with that image name which is present in the drawable folder
android:icon="#drawable/your_image_name"
To change color refer this link

Related

Using action bar in API 8

I want to use Action Bar in my applicaiton which has API level 8.
I want it like in this picture, on the top with some items in it.
http://i.stack.imgur.com/6tJ10.png
How can I do it?
Shadows answer is correct, but you can also use the appCompat support library, which is an official android support library (for what that's worth).
Use Action Bar Sherlock Library which supports for below versions too. You can integrate that in your project and do your stuff.
you can use ActionBarSherlock library.
or using android support library

Is there any benifit of ActionBarSherlock if my app run using android 4 and above

I was using ActionBarSherlock to make my app run with app version of android and use actionbar, but now I don't need to support the old version and it is enough for me to support 4 and above , is there any benefit of ActionBarSherlock still for my case ?
Not really. Feel free to use the native API Level 11+ implementation of the action bar.
Note, though, that some things in Android may steer you in the direction of using an action bar backport... though the appcompat one published by Google, not ActionBarSherlock. For example, the recommended version of MediaRouteActionButton requires the appcompat action bar, though I am maintaining a port that works with the regular action bar.

Choosing Sherlock Actionbar over Support Libraries

Why should we choose using the Sherlock Action Bar in Android rather than the Support Libraries ? Is there a solid reason for using one above the other ?
Sherlock Action Bar purpose is to add the ActionBar visual concept implementation for API level below 11 (since ActionBar was added in API level 11). Taken from ActionBar javadoc: "A window feature at the top of the activity that may display the activity title, navigation modes, and other interactive items."
Support library (as the name describes) is a jar that provides APIs added in newer versions of Android to older ones. The best example I can think of is the Fragment implementation: Added in API level 11 made it so easy to integrate different parts of UI accross the application. But that was only for API level 11 above. So when the support library was released it provided this feature for API levels below 11.
So these 2 are separate concepts (one is for UI only, while the other is for supporting newer APIs in older Android versions). To add more, Sherlock AB uses support library.
The Support Libraries did not have compatibility for the Action Bar pre Support Library revision 18 and therefore the natural choice was the ActionBarSherlock library.
However as of revision 18 release in July sometime it is now supported, how good it is I am unsure as I have not used it but in future projects I will be leaning towards the Support Library as its supported by Google.
The link to the Support Library revision notes is here.
If I'm not mistaken, the ActionBar is only available in API 11+ and the support library do not include the an ActionBar Library for API < 11. ActionBarSherlock is a library that let's you support an ActionBar in API 7+.
PS: I believe google is gonna include a ActionBar API in the support library soon. So they said in Google I/O this year.
Update:
Google added ActionBar (for API 7+) in the support library.

Android TabHost deprecated

I am creating application which will support Android 2.2 to Android 4.1. The TabHost is deprecated in Android version 3.2. But the created application supported in all the versions. But I want to create the Tab bar application which will look like a tab bar in Android 4.1 while running the application in Android 4.2, If I am running the application in below android 3.2 version device, it must look like the tab bar in that device. How can I do this.?
There are many points to your question,
TabHost is not deprecated yet. Recently Google deprecated TabActivity and ActivityGroup.
Even if it deprecated, it doesn't mean it can't be used. If X is deprecated, it only means a better alternative named Y is there.
Now to answer your question, You have more than one options
You can use ActionBarSherlock as other answers suggests. (EDIT : ActionBarSherlock is now deprecated.)
You can use TabHost with fragments, See my answer here for a
good example. To use Fragment in pre 3.0 API's you need to use
Google's support library.
Try out ActionBarSherlock.
ActionBarSherlock is an extension of the support library designed to facilitate the use of the action bar design pattern across all versions of Android with a single API.
The library will automatically use the native action bar when appropriate or will automatically wrap a custom implementation around your layouts. This allows you to easily develop an application with an action bar for every version of Android from 2.x and up.
Tutorials:
tutorial 1 , tutorial 2 ,
tutorial 3
Just to add, Android has introduced ActionBarCompat to ensure ActionBar is compatible with OS below 3.0 down to 2.1. You can use ActionBarCompat in the support library instead of ActionBarSherlock
http://android-developers.blogspot.co.uk/2013/08/actionbarcompat-and-io-2013-app-source.html

How to implement the action bar in api levels less than 11?

I recently read about the action bar implementation in android in the dev site.But i found that it requires a minimum api level of 11.Can someone tell me whether it is possible to implement action bar in Api levels less than 11 such as 8 or 9.If yes how can i do this?
ActionBarSherlock at http://actionbarsherlock.com is an Android library for implementing the action bar design pattern using the native ActionBar on 3.0+ and a third-party library on pre-3.0.
There is now also ActionBarCompat - part of the Android Support Library: http://android-developers.blogspot.co.uk/2013/08/actionbarcompat-and-io-2013-app-source.html
There are third-party implementations of the action bar available. See this library project at github: android-actionbar. The manifest says the minimum API level is 3, target API is 8.
If you are looking for a simplistic Actionbar solution you might want to give a look to ActionBarCompat from the Google Official examples

Categories

Resources