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

相关文章:

  • 2022-12-23
  • 2021-04-14
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2021-10-25
猜你喜欢
  • 2021-12-14
  • 2021-08-11
  • 2021-07-31
  • 2021-05-04
  • 2022-12-23
  • 2022-12-23
  • 2022-01-14
相关资源
相似解决方案