在布局中使用android.support.v4.app.Fragment的注意事项


1.Activity必须继承android.support.v4.app.FragmentActivity

2.fragment标签的name属性必须是完全限定包名,如下:

 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     android:layout_width="fill_parent"
 3     android:layout_height="fill_parent"
 4     android:orientation="vertical" >
 5 
 6     <fragment 
 7         android:name="com.example.v4fragmenttest.MyFragment"
 8         android:id="@+id/myfragmentid"
 9         android:layout_width="400px"
10         android:layout_height="500px"
11         android:layout_gravity="center"
12         />
13 
14 
15 </LinearLayout>

3.

onCreateView(LayoutInflater inflater,
			@Nullable ViewGroup container, @Nullable Bundle savedInstanceState)

  如果是在布局中使用Fragment,onCreateView方法的container参数是null


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM