在布局中使用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

posted @ 2016-06-01 09:09  xxNote  阅读(3185)  评论(0编辑  收藏  举报