android - 扩展 LifecycleActivity、Activity、ActionbarActivity 和 AppCompactActivity 的区别?

标签 android android-fragments android-activity android-actionbar

在 Android 中,扩展 Lifecycler Activity、Activity、ActionBarActivity 和 AppCompactActivity 的主要区别是什么?这些类在使用方面有何不同?

最佳答案

编辑:更多细节:

ActionBarActivitySupport Library 的一部分.支持库用于在旧平台上提供新功能。例如,ActionBar 是在 API 11 中引入的,默认情况下是 Activity 的一部分(实际上取决于主题)。相比之下,旧平台上没有 ActionBar。所以支持库添加了一个Activity的子类(ActionBarActivity),提供ActionBar的功能和ui

edit2:2015 年 4 月更新 - ActionBarActivity 似乎在 Support Library 的 revision 22.1.0 中已弃用。 AppCompatActivity应改为使用。

edit3: 2017 年 8 月更新 - LifecycleActivityLifecycleOwner但是:

"Since the Architecture Components are in alpha stage, Fragment and AppCompatActivity classes cannot implement it (because we cannot add a dependency from a stable component to an unstable API). Until Lifecycle is stable, LifecycleActivity and LifecycleFragment classes are provided for convenience. After the Lifecycles project is released, support library fragments and activities will implement the LifecycleOwner interface; LifecycleActivity and LifecycleFragment will be deprecated at that time."

(复制自架构组件指南)

关于android - 扩展 LifecycleActivity、Activity、ActionbarActivity 和 AppCompactActivity 的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23089547/

相关文章:

java - Gson - 从 Json 转换为类型化的 ArrayList<T>

android - (Android SDk 2.1)使用setAudioSource和setVideoSource时出现错误

java - 如何修复此错误 : InflateException: Binary XML file line #11: Error inflating class fragment

java - Android 片段被另一个片段覆盖

Android webview加载数据性能很慢

java - 如何展示测验结果?

android - 为什么我的 fragment 的 getActivity 返回 null?

android - 从 getExternalCacheDir() 获取的/storage/emulated/0 生成 "no such file or directory"错误

android - 有没有办法在样式文件中设置新的 Android 支持 AutoSize Textview?

android - Lateinit 属性 viewModel 尚未初始化