Ijsud
Ijsud

Reputation: 37

I have a problem with fragments in android incompatible fragments

The problem is the incompatible types in the fragments. Please, check down I don't know what to do know.

Here is the code:

 case R.id.mwelcome:
                  currentFragment = new WelcomeFragment(); // the problem is here incompatible types
              break;
                  currentFragment = new MapFragment();     // the problem is here incompatible types
          case R.id.map:
              break;

The problem is incopatible.

Upvotes: 0

Views: 22

Answers (1)

TheWanderer
TheWanderer

Reputation: 17874

There are two Fragment classes available in Android:

  • android.app.Fragment
  • android.support.v4.app.Fragment

Since you haven't actually provided much code, I can only guess, but I'm fairly certain your currentFragment variable is one of these Fragment types, while your WelcomeFragment and MapFragment objects are of the other type.

Make sure you're using android.support.v4.app.Fragment in everything, as android.app.Fragment has been deprecated. Check your imports and fix them if needed.

Upvotes: 1

Related Questions