The difference between the use of the fragment in the app Pack and the fragment in the V4 package

Source: Internet
Author: User

The difference between the use of the fragment in the app Pack and the fragment in the V4 package

1, try not to use the app package fragment, because this is after 3.0, the supported version is too high, in the lower version is not used


2, Android.support.v4.app.Fragment: can be compatible to 1.6 of the version,


3. Questions about the use <fragment> labeling of these two fragment
(1) Both App.fragment and v4.fragment are available with <fragment> tags.
Only in the use of the time if it is app.fragment there is no special place to inherit activity.


(2) When v4.fragment uses <fragment> tags, it should pay special attention to:
When the activity layout has a <fragment> tag, the activity must inherit
Fragmentactivity, or you'll get an error.


08-27 08:25:04.946:e/androidruntime (9839): caused By:java.lang.ClassCastException:com.example.android_fragment_ Bottom.fragments.TopBarFragment cannot is cast to Android.app.Fragment




At this point, if you do not B Ji Cheng fragmentactivity, the compilation system will think of <fragment> as the app package fragment to handle. But at this point we are importing the fragment in the V4 package.


An example of fragment in the official Android document is the fragment in the app package.


(3) The class and method of fragment in the app package have corresponding corresponding in the V4 package.

Can you see here Getsupportfragmentmanager (). The Getfragments () method disappears in the V4 package?
Http://www.eoeandroid.com/thread-328896-1-1.html
(Source: EoE Android Developer Community _android Development Forum)

The difference between the use of the fragment in the app Pack and the fragment in the V4 package

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.