DialogFragment show(FragmentManager, String) not applicable

开发 DialogFragment 遇到一个错误,关于 show() 方法的

The method show(FragmentManager, String) in the type DialogFragment is not applicable for the arguments (FragmentTransaction, String)

DialogFragment.show(FragmentManager,String) is not applicable

Cannot resolve method ‘show(android.support.v4.app.FragmentManager, java.lang.String)

这个关于 getSupportFragmentManager和getFragmentManager

代码如下

DialogFragment showDaysFragment = ClockingInFragment.newInstance(name);
showDaysFragment.show(ClockingInActivity.this.getFragmentManager(),
                    LOG_FALG);
public class ClockingInFragment extends DialogFragment {
}

老是报方法签名不匹配,找不到这个方法

查了一下,有getSupportFragmentManager和getFragmentManager

android.support.v4.app.FragmentManager getSupportFragmentManager()
android.app.FragmentManagerFragment getFragmentManager()

要根据你是android.app.DialogFragment还是android.support.v4.app.DialogFragment

android.app.DialogFragment 使用 getFragmentManager

android.support.v4.app.DialogFragment 使用 getSupportFragmentManager

你可能感兴趣的:(android,String,method,show,DialogFrag)