I have a problem with SherlockFragment. If I change "extends SherlockFragment" with "Fragment", works perfectly. But when working with Sherlock, I would it work this way.
This code is a fragment:
import com.actionbarsherlock.app.SherlockFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class Box extends SherlockFragment {
public Box(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.box, container, false);
return rootView;
}
}
In my ActivityMain.java i have this:
SherlockFragment fragment = null;
It works with Fragment fragment = null;
And i call it:
fragment= new Box();
But the problem is the .replace in this code:
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
change the getFragmentManager to getSupportFragmentManager for using sherlockfragment
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();