输入这样的代码:
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
出现此错误“android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();” 并将其作为快速修复,实际上可以消除错误:
android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
我在扩展 FragmentActivity 的主要活动中输入这个。有人知道为什么吗?我已经包括:
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;
编辑
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();
将 getSupportFragmentManager() 更改为 getFragmentManager() 需要我将 DescriptionFragment 更改为 android.app.Fragment ...有什么想法吗?