如何解决"Unknown method 'executePendingTransactions'"?

How to solve "Unknown method 'executePendingTransactions'"?

完整的错误是:“'android.support.v4.app.FragmentTransaction 的未知方法 'executePendingTransactions'”。

具体是我在用AIDE编程。

我导入了以下包(我导入了更多,但我认为这些是最相关的):

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

我必须更新一个想法吗?我该如何解决这个问题?

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

您应该在 FragmentManager 上呼叫 executePendingTransactions 而不是 FragmentTransaction

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