1

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?

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
Bryce Langlotz
  • 303
  • 1
  • 4
  • 17
  • If your minimum SDK is >= 11 you can use native fragments with `getFragmentManager()` along with support fragments with `getSupportFragmentManager()`. Also cwac-camera library is deprecated, is it not? – Eugen Pechanec May 21 '15 at 00:02
  • @EugenPechanec: It's not deprecated yet, though I am working on a replacement library that overcomes some of the original library's key limitations. – CommonsWare May 21 '15 at 10:27
  • Hi @CommonsWare I've tried both the regular and v9 installations and neither works for various reasons. Is this because of the (near) deprecation? Or am I most likely goofing something up. – Bryce Langlotz May 21 '15 at 13:20
  • 1
    @BryceLanglotz: I can't help you with unspecified "various reasons". I posted an answer yesterday with a recommended approach to creating a fragment that will work for you. If you are running into problems with that approach, post comments on that answer with more details of what those problems are. – CommonsWare May 21 '15 at 13:36

1 Answers1

1

My CWAC-Camera library has two fragment implementations:

  • one for native API Level 11+ fragments
  • one for SherlockFragment, for the ActionBarSherlock action bar backport, for historical reasons

It 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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491