简体   繁体   English

片段未在Android 4.4.4中显示

[英]Fragment is not being displayed in Android 4.4.4

I tried with support Fragment as well as normal Fragment but nothing is displayed on the screen when I call launchAwesomeFragment() in (Nexus7 4.4.4). 我尝试使用支持Fragment和普通Fragment但是在(Nexus7 4.4.4)中调用launchAwesomeFragment()时,屏幕上什么都没有显示。 But in other phones the Fragment launches perfectly. 但是在其他手机中, Fragment完美启动。

There was no errors or anything in logcat but sometimes the following log appers when I call launchAwesomeFragment() . logcat中没有错误或任何内容,但有时在我调用launchAwesomeFragment()时出现以下日志。 What might be the problem here? 这可能是什么问题?

Could not find method android.support.v4.app.Fragment.performSaveInstanceState, referenced from method .AwesomeFragment 找不到方法.AwesomeFragment引用的方法android.support.v4.app.Fragment.performSaveInstanceState

Here's my code of launchAwesomeFragment 这是我的launchAwesomeFragment代码

private void launchAwesomeFragment() {
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.container, AwesomeFragment.newInstance());
    transaction.addToBackStack(null);
    transaction.commit();
}

If you're using Eclipse, then you need to check if you've added the support library properly. 如果使用的是Eclipse,则需要检查是否已正确添加了支持库。

Project > Android Tools > Add support Library 项目> Android工具>添加支持库

Now clean and rebuild the application and then uninstall and reinstall to try again. 现在,清理并重建应用程序,然后卸载并重新安装以重试。

If you're using Android Studio, then you might try clean and build. 如果您使用的是Android Studio,则可以尝试清理并构建。 But in Android Studio, this is not an usual case. 但是在Android Studio中,这不是通常的情况。 Anyway, you might take a look at this answer here. 无论如何,您可以在此处查看此答案

Generally these type of error log indicates the method is not found as the library is not referenced properly. 通常,这些类型的错误日志表明找不到方法,因为未正确引用库。

Hope that helps! 希望有帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM