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