How to do the compatibility mode for below android versions? - android

I am developing a android application.i am using action-bar in my app.but its not working in my Android smartphone(2.2.3) crashing. give me the solution.

Use actionbar sherlock for supporting lower versions too.. follow this
Here is how to use ActionBarSherlock:
Download the ActionBarSherlock here.
Assuming you're using Eclipse IDE, right click your Project, click Properties, then Android. At the bottom, in Layout, Add ActionBarSherlock.
Make sure ActionBarSherlock and your Project are in the same directory.
Extend your classes to Sherlock naming. For example, instead of Activity, change it to Sherlock Activity. The main documentation of ActionBarSherlock is found here.
For easier usage of Sherlock, create util methods in changing the Sherlock names and modifying it.

If you just need to know ocally the android version and act according to it :
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
// do something
}
else {
// do something else
}

Related

ActionBarStyleGenerator - how to use it?

So, I have tried to use ActionBarStyleGenerator. It generates all style.xml file and all its left is to somehow set it for the action bar. The problem is that I use support libraries (app support 2.1 android) and I have issues with setting action bar style.xml to it.
Have you ever tried using this tool. If so, can you help me out and explain how to set style for the action bar?
The problem is that I use support libraries (app support 2.1 android) and I have issues with setting action bar style.xml to it.
You can set it to generate the resources for ActionBarCompat or ActionBarSherlock as well.
Since you are using the support library you have to choose AppCompat:

Android customize action bar with api<11

how can I customize my action bar with api<11? I can't use actionBarSherlock because I got an issue related to my custom rom...is there a way to do that?
You can go For sherlock Action bar. here is link for the same
Here is detailed info on how to implement it
Make sure your project uses Android 4.0+ as the build target and that
you have the compatibility/support library added. (You can
right-click the project, select Android Toots > Add Support Library)
Download the ActionBarSherlock library project and import it into
Eclipse.
Right-click your main project, select Properties, and select Android
in the left pane. In the bottom half of the window, click the Add
button and select the ActionBarSherlock project. Click OK.
Instead of using regular Activities and Fragments, you use ones from
the Sherlock Library. They have the same names, but prefixed with
"Sherlock" (SherlockActivity, SherlockFragment, etc.)
To access the actionbar in code, you call getSupportActionBar(). This
returns either the regular actionbar (for Honeycomb and later) or the
Sherlock actionbar (for pre-Honeycomb).
Theming instructions are on the ActionBarSherlock website.
You can set android:minSdk in android manifest to lower sdk say 2.2 but built have to build in target 4.
So, it will work on handsets with api level < 11.
Hope it helps.
You have to write your own ActionBar

Implementing Holoeverywhere theme without ActionBarSherlock in my Android app

I am trying to implement the holoeverywhere theme in my app.
When I implement the holoeverywhere theme, I get a actionbar by default. I think it is because of Actionbarsherlock library. I was not aware of this library and have implemented my own actionbar of sorts. So, how do I disable the actionbar that comes up now.
If you need any relevant portions of my code, please let me know. Thanks
Removed ABS depends from HoloEverywhere... It's hard and don't supported by me.
First. Remove full library/src/com/actionbarsherlock from HE.
Second. Change library/resources/*.json to extend from standart android themes, not sherlock. Rebuild styles by mvn resbuilder:styler
Third. Remove fake-actionbar from PreferenceScreen code.
Fourth. Edit library/src/org/holoeverywhere/app/Activity and remove all related to ABS and remove Sherlock addon.
Fifth. Uncomment special block in library/res/values/attrs.xml. Straight from the top.
Sixth. Pray to Cthulhu and make a couple of tricks ears.
Once there was a branch nosherlock. Not popular.
In the HoloEverywhere library included in my project, in the res>values>styles.xml file, there is a theme called Holo.Theme.Light.NoActionBar. I use that instead of Holo.Theme.Light which I used earlier. This fixed the issue. Thanks.

Action Bar in API < 3.0 With Google Maps Compatability Library

Yet another compatibility problem from me.
BACKGROUND
I have an application that works in all API's now that I downloaded a custom google maps compatibility support library which is an extension of the Compatibility Support Library and allows me the have fragments along with maps in API levels < 3.0. It does this by making me extend my activity by FragmentActivity, which due to this custom library is also a subclass of MapActivity.
THE PROBLEM
I also need to implement a tabbed Action Bar throughout my application on different API levels. It's possible to do this using ActionBarSherlock. However, that also involves downloading and extending my Activity`` byFragmentActivity` using this custom library and thats a problem as I then lose the ability to have maps because I can't extend using both libraries versions?
THE QUESTION
How can I have both features in my application?
If this isn't the way to do it, how can I do it?
Thanks in advance.
UPDATE
So I have implemented a system where I can display the action bar in api's greater than 3.0 and not display if they aren't.
Here is the code.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.show();
} else {
//Do something else
}
POSSIBLE SOLUTION
Would the best way to go about it be to create a custom ActionBar Module that is just a group of views with some functions to make it act and look like an action bar?
Do you try to extend your FragmentActivity by SherlockActivity ?
So here is the solution that I came up with.
ActionBarSherlock wasn't an option for me due to the fact I was already using a version of the compatability library that allowed me to use GoogleMaps along with Fragments and if I used the ActionBarSherlock library I would have lost this functionality.
My Solution
I decided to implement my own custom ActionBar which is a combination of Views and TextViews.
I have one class extending Fragment (the android support version) called CCActionBar and this inflates three custom objects called CCTab which extend TextView. These three tabs (as it says in the name) are acting as my tabs so we override when they get touched, pass them to our CCActionBar which may then pass it onto our MainActivity to handle any navigation.
To detect if we need to create this Custom Action Bar due to API level I use the following code.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
//setup a normal action bar because the api level supports it
} else {
//setup our custom action bar
}
So that's my solution, it may not be the correct one but it works for me.
Any questions please ask.

implement action bar on android API 7

I am working on Android 2.1 with API v7.
How can I implement the action bar in this old version API which can work like built-in ActionBar on devices supporting API 11 or greater? Is there any support package ?
(A good tutorial on how to implement action bar in old version API is appreciated)
Here is an examle of adding actionBar with slides menu to api>7:
https://github.com/BradleyRL/NavDrawerExampleAppCompat-v7
It's documented here for api>14 http://developer.android.com/training/implementing-navigation/nav-drawer.html. (first link - is upgraded method of second link to support previous versions).
Then, you could read documentation here: developer.android.com/guide/topics/ui/actionbar.html
To do this this way you must add project library to your project (and for exammple in 1t link too).
To do it: File>New>Other>Android Project From Existing Code>Browse (Select "YOUR_PATH_TO_ANDROID_SDK\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk\extras\android\support\v7\appcompat"), check adding it to workspace>Finish.
Then go to properties of your(example in 1st link) project>android>add (choose this library)>OK.
And you must extend your main class from ActionBarActivity insted of Activity. I try this, and it work on 2.3.7 and on 4.1.1 versions)
Hope it helps)
P.S. Sorry for my bad english and hi from Russia)
You can/should use this ActionBar project.
It's very very simple to use and I am using it myself in one project.

Categories

Resources