industrychanger
industrychanger

Reputation: 573

How to replace Fragment with FragmentActivity

I'm trying to load a FragmentActivity from another FragmentActivity (instead of a Fragment), but am getting an error. Is there a way to accomplish this?

@SuppressLint("NewApi")
private void displayView(int position) {
    if (getSupportFragmentManager().findFragmentByTag(Tab_Day.TAG) == null) {
        getSupportFragmentManager().beginTransaction()
            .replace(android.R.id.content, fragmentAct, Tab_Day.TAG).commit();
        mDrawerList.setItemChecked(position, true);
        mDrawerList.setSelection(position);
        setTitle(navMenuTitles[position]);
        mDrawerLayout.closeDrawer(mDrawerList);
    }

}

This is the error that I get:

The method replace(int, Fragment, String) in the type FragmentTransaction is not applicable for the arguments (int, FragmentActivity, String)

Upvotes: 0

Views: 4852

Answers (1)

JRomero
JRomero

Reputation: 4868

FragmentActivity is not a subclass of Fragment it is a subclass of Activity. If you are trying to start a new activity then you use startActivity(Intent intent) otherwise fragmentAct should be a Fragment.

They are not interchangeable. A FragmentActivity hosts Fragments.

Upvotes: 4

Related Questions