Android--fragment long time home or lock screen Java.lang.IllegalArgumentException:No view found for ID ....

Source: Internet
Author: User

This problem was encountered in the project. Headache for a long time, always can not reproduce, and can not be solved well. Always after the interest screen for a period of time, it will be reported java.lang.IllegalArgumentException:No view found for the ID for .... Problem, and then the program crashes. I believe a lot of friends have the same problem as me. So how to solve this problem?

After careful study of fragment's manager, here's what I found

What the heck? How can there be two of Fragmentmanager. What's the matter with these two things?

The API says a lot, and here's a brief summary.

If fragment is in replace new fragment, the container uses a part of the activity layout or the whole as a container, then use Getfragmentmanager ();

That is, the Getfragmentmanager is the manager of the activity to the included fragment.

If fragment is in replace new fragment, the container uses the fragment layout file of a whole or part of view as a container, then it is used Getchildfragmentmanager ();

That is: fragment nested fragment, you need to use Getchildfragmentmanager ()

Android--fragment long time home or lock screen Java.lang.IllegalArgumentException:No view found for ID ....

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.