Today in the company encountered a android.app.Fragment and android.support.v4.app.Fragment problem.
(1) Android.app.Fragment: The minimum compatible version is android:minsdkversion= "11" so your app is not compatible with apps under 3.0.
can use the <fragment> label, this is very important, if the use of android.support.v4.app.Fragment words, is not to use the <fragment> tag, Will throw android.view.InflateException:Binary XML file line #7: Error inflating class fragment exception
(2) Android.support.v4.app.Fragment: can be compatible to 1.6 version, cannot use <fragment> tag, need to be added in the program by add or replace, but also need
Android-support-v4.jar
Two fragment manager get noticed differently
The first android.app.Fragment layout ----Manager Getfragmentmanager//Get manager
<fragment android:id= "@+id/fragment1" android:layout_width= "wrap_content" android:layout_height = "Wrap_content"/>
The second android.support.v4.app.Fragment way the main activity must inherit fragmentactivity---------Manager getsupportfragm Entmanager get the manager
Note the imported package
The first way of layout
<fragment android:id= "@+id/fragment1" <span style= "color: #ff0000;" ><strong>android:name= "Com.text.fragment" </strong></span> android:layout_width= "Wrap_ Content " android:layout_height=" Wrap_content "/>
Notice that the name above is the path address of your child fragment.
The second way of layout
<framelayout android:id= "@+id/fragment1" android:layout_width= "wrap_content" android:layout_ height= "Wrap_content"/>
Both types cannot be mixed using special attention. Hope to be helpful.
Android.support.v4.app.Fragment and Android.app.Fragment differences