javaandroidandroid-fragmentsaide-ide

How to solve "Unknown method 'executePendingTransactions'"?


The full error is: "Unknown method 'executePendingTransactions' of 'android.support.v4.app.FragmentTransaction".

The detail is that I'm programming with AIDE.

I've imported the following packages (I've imported more, but these are the most relevant, I think):

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;

Must I update a think? How can I solve this problem?


Solution

  • Unknown method 'executePendingTransactions' of 'android.support.v4.app.FragmentTransaction.

    You should be calling executePendingTransactions on the FragmentManager not FragmentTransaction.

    FragmentManager mFragmentManager = getSupportFragmentManager();
    FragmentTransaction mFragmentTransaction = mFragmentManager.beginTransaction();
    Fragment fragment = mFragmentManager.findFragmentById(R.id.main_content);
    mFragmentManager.executePendingTransactions();