在我的应用程序中,我使用对话框片段作为启动画面。因此它将在应用程序启动时显示启动画面。当我在 android 版本 3 以下的设备上运行该应用程序时,它会显示类似“ No such method error:getFragmentManager
”的错误。我已经看到可以通过使用来解决它getSupportFragmentManager()
。但是当我使用它时,没有显示 Splash 对话框。请有人帮助我..提前致谢...
主要活动=>
ft = getFragmentManager().beginTransaction(); //Here I am using getFragmentManager
newFragment = SplashDialogFragment.newInstance();
newFragment.show(MainActivity.ft, "dialog");
这是我的启动画面片段=>
public class SplashDialogFragment extends DialogFragment {
private EditText mEditText;
static SplashDialogFragment newInstance() {
SplashDialogFragment f = new SplashDialogFragment();
return f;
}
public void EditNameDialog() {
// Empty constructor required for DialogFragment
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.splash_fragment, container);
return view;
}
public void show(FragmentManager supportFragmentManager, String string) {
// TODO Auto-generated method stub
}
}
和错误日志=>
> 12-07 11:09:09.330: E/AndroidRuntime(628): FATAL EXCEPTION: main
12-07 11:09:09.330: E/AndroidRuntime(628): java.lang.NoSuchMethodError: com.myapp.mlm.MainActivity.getFragmentManager
12-07 11:09:09.330: E/AndroidRuntime(628): at com.madhyamam.malayalam2.MainActivity.onCreate(MainActivity.java:103)
12-07 11:09:09.330: E/AndroidRuntime(628): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-07 11:09:09.330: E/AndroidRuntime(628): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
12-07 11:09:09.330: E/AndroidRuntime(628): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-07 11:09:09.330: E/AndroidRuntime(628): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-07 11:09:09.330: E/AndroidRuntime(628): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-07 11:09:09.330: E/AndroidRuntime(628): at android.os.Handler.dispatchMessage(Handler.java:99)
12-07 11:09:09.330: E/AndroidRuntime(628): at android.os.Looper.loop(Looper.java:123)
12-07 11:09:09.330: E/AndroidRuntime(628): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-07 11:09:09.330: E/AndroidRuntime(628): at java.lang.reflect.Method.invokeNative(Native Method)
12-07 11:09:09.330: E/AndroidRuntime(628): at java.lang.reflect.Method.invoke(Method.java:507)
12-07 11:09:09.330: E/AndroidRuntime(628): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-07 11:09:09.330: E/AndroidRuntime(628): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-07 11:09:09.330: E/AndroidRuntime(628): at dalvik.system.NativeStart.main(Native Method)