简体   繁体   English

如何在我的Android应用程序中添加动作栏标签,使其跨平台兼容?

[英]How can I add actionbar tabs to my Android application so that it is cross platform compatible?

I have developed an Android app that targets API 7. Now I want to add these tabs http://developer.android.com/training/implementing-navigation/lateral.html . 我已经开发了一个针对API 7的Android应用。现在,我想添加以下标签http://developer.android.com/training/implementing-navigation/lateral.html

When trying to implement this I run into the problem that my app targets api 7 and that some action bar require a higher api. 尝试实现此功能时,我遇到了我的应用程序针对api 7的问题,并且某些操作栏需要更高的api。 For example, one of my errors is 例如,我的错误之一是

Call requires API level 14 (current min is 7): android.app.ActionBar#setHomeButtonEnabled

So now my question is: How can I work around this problem? 所以现在我的问题是:我该如何解决这个问题? What are my options? 我有什么选择?

I have heard of something like 'actionbar sherlock'. 我听说过类似“ actionbar sherlock”的内容。 Would that help with my actionbar tabs? 这对我的操作栏标签有帮助吗? And if so, how do I add that library to my project? 如果是这样,如何将该库添加到我的项目中?

Thanks! 谢谢!

I think you can use ActionBarSherlock. 我认为您可以使用ActionBarSherlock。 You have to target api 11 but you can set the min lower than that. 您必须以api 11为目标,但是您可以将min设置为低于该值。

Targetting API level 11 or newer is required as it will cause Android to automatically add the native action bar when run on newer devices. 需要定位API级别11或更高版本,因为它会导致Android在较新设备上运行时自动添加本机操作栏。 Since you will be compiling against new APIs but your app will likely be run on devices with older versions of Android extra care must be taken to either avoid using or properly check and call any methods that were introduced after your minimum SDK version. 由于您将使用新的API进行编译,但是您的应用可能会在具有旧版Android的设备上运行,因此必须格外小心,以避免使用或正确检查并调用最低SDK版本之后引入的任何方法。

The instruction is here . 指令在这里

Also, ActionBarSherlock gives tons of "Call requires API level 11 (current min is 7)" errors might be helpful. 另外, ActionBarSherlock会产生大量的“调用要求API级别11(当前最小值为7)”错误,可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM