I have a class which creates a behindMenu for a Sliding Menu as follows:
public class BehindMenuFragment extends ListFragment {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
String[] categories = getResources().getStringArray(R.array.categories);
CategoryAdapter adapter = new CategoryAdapter(getActivity());
int cats = categories.length;
for (int i = 0; i < cats; i++) {
adapter.add(new CategoryItem(categories[i], getIcon(categories[i])));
}
setListAdapter(adapter);
}
It gets called from another activity MainActivity with the following code:
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.menu_frame, new BehindMenuFragment ())
.commit();
The above code works fine no problems, I want to insert an Action Bar using ActionBarSherlock to the behind menu I’ve tried it in every way possible to no avail.
Extending BehindMenuFragment as a SherlockListFragment gives me the following error:
IllegalStateException: BehindMenuFragment must be attached to a SherlockFragmentActivity
Im at a loss and don’t know how to move forward with this problem please help!
It appears you haven’t done step four:
Having never worked with this library I would guess that you should change MainActivity to:
Now you can use a SherlockListFragment:
And add Sherlock’s ActionBar.