Problem Record-fragment Guide package is not automatically transformed

Source: Internet
Author: User

The code is as follows

1  Public classMainactivityextendsfragmentactivity {2 3 @Override4      Public voidonCreate (Bundle savedinstancestate) {5         Super. OnCreate (savedinstancestate);6 Setcontentview (r.layout.activity_main);7Fragmentmanager fm=Getsupportfragmentmanager ();8Fragment fragment=Fm.findfragmentbyid (r.id.fragmentcontainer);9         if(Fragment = =NULL) {Ten            fragment=new crimefragment (); One fm.begintransaction () A . Add (R.id.fragmentcontainer, fragment) - . commit (); -         } the     } -}

The red part is an error because the type is different. But Crimefragment has inherited the fragment, should be automatically transformed.

Think the code error, check several, and finally by the predecessor reminded, import jar package When there is a problem.

In the Mainactivity import is backward compatible import android.support.v4.app.Fragment;

Import Android.app.Fragment is imported in crimeactivity;

Problem Record-fragment Guide package is not automatically transformed

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.