Is using ActionBarSherlock still necessary?
Asked Answered
F

1

8

Up until earlier today, I was under the impression that if I wanted to use ActionBar on devices lower than SDK version 11, I would need to use ABS. But, after looking at some questions on SO here, I came upon this: http://developer.android.com/resources/samples/ActionBarCompat/index.html

This system looks like it provides a fully functioning actionbar system on preHoneycomb devices. Specifically, though I don't see anything in those classes concerning actionbar tabs. Has anyone managed to use this actionbarhelper class with actionbartabs?

Does anyone have any experience using both of these systems? I'm having a heck of a time trying to import my android project to work with ABS, whether it was getting my R file to link, bringing the manifest into the folder, getting the correct package names so my activities would launch, and beyond all that, the highly cluttered src folder. So if it's possible to use this Google-provided code instead, I think it might be desirable - if it is possble to use tabs?

Fairtrade answered 31/3, 2012 at 19:45 Comment(2)
Integrating ABS is simple and easy if you know what you are doing. The ActionBarCompat utility is useful but it doesn't handle anywhere near as many features ABS does. It handles the very basic ActionBar.Dissogeny
I never said I knew what I was doing. This is my first application on Android and it's been a beast just getting to the point where I can say I have a fully functioning ViewPager, TabAdapter, system of fragment tabs, and some basic login/register features from an SQL server. I'll take away from your comment the idea that I should force my way through getting ABS to function rather than try and set up ActionBarCompat.Fairtrade
S
10

This system looks like it provides a fully functioning actionbar system on preHoneycomb devices.

ActionBarCompat is not "fully functioning", as compared to the native action bar or ActionBarSherlock.

Has anyone managed to use this actionbarhelper class with actionbartabs?

It does not support tabs.

I'm having a heck of a time trying to import my android project to work with ABS, whether it was getting my R file to link, bringing the manifest into the folder, getting the correct package names so my activities would launch, and beyond all that, the highly cluttered src folder.

Step #1: Download the ABS ZIP file.

Step #2: Import the project (in library/) into Eclipse, marking it to compile with Android 4.0 or higher.

Step #3: Add it as a library project to your existing project.

Step #4: Inherit from SherlockActivity or related classes (e.g., SherlockListActivity), and update other references (e.g., MenuInflater) to Sherlock equivalents as needed.

Step #5: Add Theme.Sherlock to your <application> or <activity> elements.

And that's pretty much it, beyond what you would ordinarily do to use the native action bar.

So if it's possible to use this Google-provided code instead, I think it might be desirable

Code in the "samples" area of the Android Developers site is just that: sample code. The code is unsupported, un-maintained (some don't even work anymore), etc. If you would prefer to use such code over a component that has many more engineers using it, has its own support group, etc., you are welcome to do so.

This is my first application on Android and it's been a beast just getting to the point where I can say I have a fully functioning ViewPager, TabAdapter, system of fragment tabs, and some basic login/register features from an SQL server.

Then perhaps you should start with a simpler app. What you are describing is not what I would recommend somebody start with, unless they are getting specific guidance (e.g., a set of tutorials).

Santa answered 31/3, 2012 at 20:26 Comment(11)
Thank you CommonsWare. I've gotten to point of loading my app with ABS running, but not to the point that it actually functions with Gingerbread or lower. So, the point about being a pain was more gripe than failure. I'm still not comfortable with the added bulk into the application, but if it's necessary in order to provide compat, I'll do it. Beyond that? As I said, I've managed to get the ViewPager/TabAdapter/Fragments all to function perfectly. I can register and login via SQL/PHP with my website. All that's left is a little more SQL and the app is done - provided I get compat working too.Fairtrade
I should also note that I've gone through two android books, one app-driven, the other reference. And am currently driving through a PHP/SQL book. While it's been rough going, it's rewarding. SQL was such a pain to get running in terms of errors, but seeing as how the light is at the end of the tunnel with this app, I hope to get the backwards compatibility up and running soon :)Fairtrade
@Davek804: Sorry, I misinterpreted your "it's been a beast" to suggest you were still working on those capabilities.Santa
No biggie. For the amount of help you've lent me over the last couple of weeks in multiple threads, I'll let it slide. I may respond here again if I have any further trouble getting ABS to run, though.Fairtrade
I tried adding ActionBarSherlock. I added it as a Library to my existing project and it threw a lot of errors (sample below). I tried setting the Theme to Theme.Sherlock but I still got the same error. JakeWharton-ActionBarSherlock-88fc341/library/res/values-v14/abs__styles.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar'.Ostracoderm
@dannyroa: To use ActionBarSherlock, you need to set your build target to API Level 14 or higher. This does not impact your android:minSdkVersion -- you will still be able to support apps going back to API Level 7.Santa
Mark, you say "It does not support tabs.", but isn't it "It does not support tabs on <4.0"? Because basically you have a dual structure and you can still use all native Action Bar features on the platforms they were introduced on.Fallon
@pjv: The question was about ActionBarCompat. ActionBarCompat does not support tabs on any Android version. If you choose to not use ActionBarCompat for some versions, that is your decision, and then there are ways of getting tabs. But ActionBarCompat does not support tabs on any Android version.Santa
Is this still current? Is ABS an improvement over compatibility library anymore?Danseur
@kelmer: There are pros and cons to each. ABS has a better track record; AppCompat has the Google seal of approval. ABS requires you to modify your classes; AppCompat requires you to modify your menu resources. ABS has a lot more written about it; AppCompat... did I mention that it has the Google seal of approval? :-) It's unlikely you will go terribly wrong with either choice, but there's no good reason that I am aware of for taking an existing app using ABS and switching. For new apps, choose whichever one makes you feel more comfortable.Santa
if you don't plan to support v2.x android devices, no reason to use ABS. Take it from the guy who wrote it : jakewharton.com/deprecated-from-inceptionViki

© 2022 - 2024 — McMap. All rights reserved.