编写 Android 库:使用 AppCompat?
Writing an Android library: use AppCompat?
编写 Android 库时,我应该使用支持库提供的 AppCompat
还是 Support
变体?
例如,方法应该采用 Activity
还是 AppCompatActivity
? support.v4.Fragment
或 android.app.Fragment
?
一般来说,您应该尽可能使用 AppCompat 库。该库为一些新功能(任何实用的)提供反向移植,并修复各种版本特定版本中的错误。对于 Activity 和 Fragments 这一点尤为重要,因为 Fragments 至少在版本之间存在重大差异。
AppCompatActivity 是支持库 ActionBar 的基础 class 而 Activity 实际上是 AppCompatActivity 的父级。根据您使用库的目的,如果您不打算在您的库中使用支持库 ActionBar / Fragment 相关功能,我会说,一般来说,activity class 对您的库来说已经足够了。
android.app.Fragment has been deprecated now with API 28. So just go for the support Fragment version。
编写 Android 库时,我应该使用支持库提供的 AppCompat
还是 Support
变体?
例如,方法应该采用 Activity
还是 AppCompatActivity
? support.v4.Fragment
或 android.app.Fragment
?
一般来说,您应该尽可能使用 AppCompat 库。该库为一些新功能(任何实用的)提供反向移植,并修复各种版本特定版本中的错误。对于 Activity 和 Fragments 这一点尤为重要,因为 Fragments 至少在版本之间存在重大差异。
AppCompatActivity 是支持库 ActionBar 的基础 class 而 Activity 实际上是 AppCompatActivity 的父级。根据您使用库的目的,如果您不打算在您的库中使用支持库 ActionBar / Fragment 相关功能,我会说,一般来说,activity class 对您的库来说已经足够了。
android.app.Fragment has been deprecated now with API 28. So just go for the support Fragment version。