如何在Android中没有编译器警告你的版本code? [英] How do you version code in Android without compiler warnings?

查看:126
本文介绍了如何在Android中没有编译器警告你的版本code?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌的文档说使用这种code,以确保新的code未在老平台上执行:

Google's docs say to use this kind of code to ensure new code is not executed on old platforms:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
}

但是,当我这样做时,Eclipse仍然给我的警告:调用需要API级别11(目前最小为7)。我要的是有我的最低版本设置为除蜂窝东西时,具备上述条件语句保护我从运行旧设备新的code和的没有的有编译器警告。

But when I do that, Eclipse still gives me warnings: "Call requires API level 11 (current min is 7)". What I want is to have my minimum version set to something lower than Honeycomb, have the above conditional statement protect me from running new code on old devices, and not have compiler warnings.

我该怎么办呢?

推荐答案

添加 @TargetApi(11)之前的方法。

这篇关于如何在Android中没有编译器警告你的版本code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆