entering in code like this:
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
comes up with this error "android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();" and has this as a quick fix which does in fact remove the error:
android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
and i am typing this in my main activity which extends FragmentActivity . Does anybody know why? i have included:
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
EDIT
DescriptionFragment fragment = new DescriptionFragment();
android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.pager, fragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.commit();
changing getSupportFragmentManager() to getFragmentManager() requires me to change DescriptionFragment to android.app.Fragment...any ideas?
With getSupportFragmentManager() you are getting the supportLibrary fragmentManager instead of the systems fragmentManager. So you are working with a transaction of the supportlibrary.
This is the reason why you need to add all these imports and use android.support.v4.app.
If you want to get the systems fragmentManager just try to use getFragmentManager() instead getSupportFragmentManager().
Hope this helps
try this
public class DescriptionFragment extends android.support.v4.app.Fragment
instead of simply Fragment.
Have you import android.support.v4.jar file to your project??
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With