Search code examples
androidandroid-fragmentsactionbarsherlockandroid-support-library

Android ActionBarSherlock Fragment


I've been trying to get ActionBarSherlock working with Google's fragment tutorial and run into a problem when trying to add the "content" fragment to the view. This line produces the following exception

getFragmentManager().beginTransaction().add(android.R.id.content, content).commit();

The method add(int, Fragment) in the type FragmentTransaction 
is not applicable for the arguments (int, ContentFragment)

The code is identical to Google's (http://developer.android.com/guide/components/fragments.html) except I've extended to SherlockActivity where needed. ContentFragment/Activity is merely what I've called Details activity.

Even if I take out all of the ABS references to make it a normal example, I get the same problem. I have a feeling its to do with the android support library, but I cant for the life of me figure it out.


Solution

  • Use getSupportFragmentManager() instead of getFragmentManager().