Unable to use Getfragmentmanager () in activity

Source: Internet
Author: User

Should be used in the activity

Getsupportfragmentmanager ()

If you use

Getfragmentmanager ()

, in the jump custom fragment will compile an error.

Wrong 2nd argument type ....

Using Getfragmentmanager () in a custom fragment is no problem.

By viewing the source, acrivity in Getfragmentmanager () is

Package Android.app;

Package under the code, while fragment is

Package Android.support.v4.app;

Under the. It's like there are two families in the family who cannot duplicate the same name,

Package Android.app

There is a small Ming, and V4 under a small Ming.

Then the custom fragment is V4 under the Xiao Ming, if in the activity with Getfragmentmanager () forcibly gave Android.app, that Android.app pit will not agree.

If you use

Getsupportfragmentmanager ()

There is no problem, because he is under the V4, so you can send this xiaoming back to V4.

Unable to use Getfragmentmanager () in activity

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.