在我的應用程序中,我使用Dialog片段作爲啓動畫面。所以它會在應用程序啓動時顯示啓動畫面。當我在Android版本3以下的設備上運行應用程序時,它顯示「No such method error:getFragmentManager
」這樣的錯誤。我看到它可以通過使用getSupportFragmentManager()
來解決。但是當我使用它時,Splash對話框不顯示。請幫助我..Thanks提前...當在android中使用getfragmentmanager()時出現「沒有這樣的方法錯誤」
主要活動=>
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)
我需要做些什麼來解決這個問題? –