当我尝试通过在活动中声明 FragmentTransaction ft = getFragmentManager().beginTransaction() 来替换片段时,我总是有以下错误警报:
import android.support.v4.app.FragmentTransaction;
public class MainFrameActivity extends ActivitySupport {
FragmentTransaction ft = getFragmentManager().beginTransaction();
switch (position) {
case 0:
ft.replace(R.id.content_frame, fragmentDiscover);
break;
case 1:
ft.replace(R.id.content_frame, fragmentPersonInfo);
break;
}
ft.commit();
mDrawerList.setItemChecked(position, true);
mDrawerLayout.closeDrawer(mDrawerList);
}
并且该类是 ActivitySupport 继承自:
public class ActivitySupport extends Activity implements IActivitySupport {
我试图将 getFragmentManager 更改为 getSupportFragmentManager(),并且警告该方法未定义变得更加糟糕。
那么我该怎么做才能使 getFragmentManager() 成为 v4 支持的方法呢?