This is an import problem. Your Activity
doesn't use the support library, so FragmentTransaction.add
is expecting a Fragment
of type android.app.Fragment
whereas you are providing a BarcoreFragment
which extends android.support.v4.app.Fragment
;
You can fix that by changing your MainActivity
and make it implement FragmentActivity
(see doc here), then fixing your imports and making the following changes :
import android.app.FragmentTransaction;
import android.app.Activity;
MainActivity extends Activity
FragmentTransaction ft = getFragmentManager().beginTransaction();
becomes
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.FragmentActivity;
MainActivity extends FragmentActivity
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();