FragmentActivity和Activity的区别及何时使用两者
16lz
2021-01-26
区别:A FragmentActivity
is a subclass of Activity
that was built for the Android Support Package.
The FragmentActivity
class adds a couple new methods to ensure compatibility with older versions of Android, but other than that, there really isn't much of a difference between the two. Just make sure you change all calls to getLoaderManager()
and getFragmentManager()
to getSupportLoaderManager()
and getSupportFragmentManager()
respectively.
使用:use Activity
if you are using android.app.Fragment
; use FragmentActivity
if you are using android.support.v4.app.Fragment
. Never attach a android.support.v4.app.Fragment
to a android.app.Activity
, as this will cause an exception to be thrown.
http://stackoverflow.com/questions/10477997/difference-between-activity-and-fragmentactivity
更多相关文章
- Android(安卓)对象序列化 Serializable实现与Parcelabel实现的区
- 802.11(wifi)中SSID、BSSID、ESSID的区别
- getExternalFilesDir()与getExternalStorageDirectory()区别
- Android(安卓)fill_parent、wrap_content和match_parent的区别
- Flutter系列之UI篇:flutter与android UI构建的区别—flutter widg
- Android比iOS卡得原因和本质区别总结
- android的Thread、Runnable、Asyntask的区别与联系
- android相对布局中@id和@+id的区别(原理)
- Hbuilder集成个推时Android和ISO中推送的区别