Question

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?

Was it helpful?

Solution 2

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.

OTHER TIPS

Do you try to extend your FragmentActivity by SherlockActivity ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top