日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Fragment之一:基本原理

發布時間:2024/1/23 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Fragment之一:基本原理 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


1、低版本API對Fragment的支持

Fragment必須被加載進Acitivity中,才能呈現。而在低于3.0版本的API中,由于不存在Fragment,因此必須使用support包:

(1)對于1.6(API=4)及以上版本:

?創建Fragment時,應該繼承android.support.v4.app.Fragment;

?創建Activity時,應該繼承android.support.v4.app.FragmentActivity;

(2)對于2.1(API=7)及以上版本:(為同時支撐ActionBar)

創建Fragment時,應該繼承android.support.v4.app.Fragment;(這個還需要確認一下)

創建Activity時,應該繼承android.support.v7.app.ActionBarActivity

(3)他們之間的關系為:

java.lang.Object
? ?? android.content.Context
? ? ? android.content.ContextWrapper
? ? ?android.view.ContextThemeWrapper
? ? ?android.app.Activity
? ? ?android.support.v4.app.FragmentActivity
? ? ?android.support.v7.app.ActionBarActivity


2、addToBackStack()

Keep in mind that when you perform fragment transactions, such as replace or remove one, it's often appropriate to allow the user to navigate backward and "undo" the change. To allow the user to navigate backward through the fragment transactions, you must call addToBackStack() before you commit the FragmentTransaction.

3、Fragment之間的通信
To allow a Fragment to communicate up to its Activity, you can define an interface in the Fragment class and implement it within the Activity.

總結

以上是生活随笔為你收集整理的Fragment之一:基本原理的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。