Android Action 兼容性从 2.2 到 4.2

标签 android android-actionbar actionbarsherlock

我正在尝试在 Android 上创建一个应用程序,并希望将应用程序一直定位到 Android 2.2。

我对如何配置应用程序有点困惑

最低 SDK:2.2 目标 SDK:4.1 编译 SDK 针对:4.2

这是我创建新 Android 项目时获得的默认配置。

我还需要使用 ActionBar Sherlock 来支持旧版本吗?

最佳答案

除非您使用任何不适用于较低版本的 API,否则您将不需要任何额外的库,例如 ActionBarSherlock。

但是,如果您正在使用任何特定的 API 并希望它们向后兼容,例如 FragmentsActionBar 等,那么您可以使用 Support Library,它支持最低 API 级别 4。

引自支持库页面:

Minimum API level supported: 4

The Support Package includes static "support libraries" that you can add to your Android application in order to use APIs that are either not available for older platform versions or that offer "utility" APIs that aren't a part of the framework APIs. The goal is to simplify your development by offering more APIs that you can bundle with your application so you can worry less about platform versions.

ABS 是支持库的扩展。这是来自 ABS 页面链接:ActionBarSherlock:

The library will automatically use the native action bar when appropriate or will automatically wrap a custom implementation around your layouts. This allows you to easily develop an application with an action bar for every version of Android from 2.x and up.

总而言之,如果您要使用旧版 SDK 中不可用的 API,则可以使用上面列出的两者之一。如果您使用特定于较新 SDK 的 API,则不需要 ABS 或支持库。

关于Android Action 兼容性从 2.2 到 4.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13524604/

相关文章:

android - 使用 Mapbox SDK 在 Android 中实现逐向导航

Android - Activity Home/向上箭头在 SDK 24 中有额外的填充/边距

android - 更改支持 ActionBarDrawerToggle 图标

android - 操作按钮隐藏在溢出中

java - 膨胀类 com.actionbarsherlock.internal.widget.ActionBarContainer 时出错

android - 将 EditText 传递给 Toast

android - 自动为文档生成 ID,而不是在 firestore 中生成集合

android - 将纯文本作为 POST 正文发送会导致改造出现问题

android - 无法在Android Fragment中加载简单的ListView

android - 在 ViewPager 中使用选项卡时出现错误 "Java.lang.IllegalStateException Activity has been destroyed"