Reputation: 323
The fragment manager looks like this:
FragmentManager fragmentManager = getSupportFragmentManager();
switch (position) {
case 0:
fragmentManager.beginTransaction()
.replace(R.id.container, ReviewFragment.newInstance(position + 1))
.commit();
break;
case 1:
fragmentManager.beginTransaction()
.replace(R.id.container, RedeemFragment.newInstance(position + 1))
.commit();
break;
case 2:
fragmentManager.beginTransaction()
.replace(R.id.container, MyAccountFragment.newInstance(position + 1))
.commit();
break;
case 3:
ParseUser.logOut();
presentLoginActivity();
break;
}
and the error is on the line:
case 0:
fragmentManager.beginTransaction()
.replace(R.id.container, ReviewFragment.newInstance(position + 1))
.commit();
and the error reads:
Wrong second argument type. Found: 'blah.blah.blah.MainActivity.ReviewFragment', required: 'android.support.v4.app.Fragment'
The CameraFragment is from cwac-camera-0.6.12.jar
public static class ReviewFragment extends CameraFragment
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static ReviewFragment newInstance(int sectionNumber) {
ReviewFragment fragment = new ReviewFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
public ReviewFragment() {
}
...
}
I know that the CameraFragment is android.app.Fragment and I've tried changing the getSupportFragmentManager(); to getFragmentManager(); and change all the other Fragment subclasses to subclass of android.app.Fragment but it still doesn't work. Ideas?
Upvotes: 1
Views: 957
Reputation: 1006869
My CWAC-Camera library has two fragment implementations:
SherlockFragment
, for the ActionBarSherlock action bar backport, for historical reasonsIt does not contain a fragment that simply extends the fragment backport's Fragment
class.
That being said, creating your own should take just a couple of minutes. Copy this class into your project and change it to extend android.support.v4.app.Fragment
instead of SherlockFragment
. In a quick scan of the code, I don't see any other changes that would need to be made.
Upvotes: 1