坚持@燮pressLint(" NewApi")(developer.android.com/training/basics/firstapp/starting-activity) [英] Stuck with @SuppressLint("NewApi") (developer.android.com/training/basics/firstapp/starting-activity)

查看:163
本文介绍了坚持@燮pressLint(" NewApi")(developer.android.com/training/basics/firstapp/starting-activity)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和Android的一个初学者,目前套牢lession:<一href="http://developer.android.com/training/basics/firstapp/starting-activity.html">http://developer.android.com/training/basics/firstapp/starting-activity.html

I'm a begginer with Android and currently stuck with the lession: http://developer.android.com/training/basics/firstapp/starting-activity.html

在部分创建第二个活动,当我尝试使用code:

In the part Create the Second Activity, when I try to use the code:

public class DisplayMessageActivity extends Activity {

    @SuppressLint("NewApi")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_display_message);

        // Make sure we're running on Honeycomb or higher to use ActionBar APIs
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            // Show the Up button in the action bar.
            getActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case android.R.id.home:
            NavUtils.navigateUpFromSameTask(this);
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

我收到以下错误:

I get the error below:

@燮pressLint(NewApi) - >属性值是不确定的注释类型燮pressLint

@SuppressLint("NewApi") -> The attribute value is undefined for the annotation type SuppressLint.

如果(Build.VERSION.SDK_INT> = Build.VERSION_ codeS 蜂窝。) - >蜂窝不能得到解决,或者不是一个领域

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) -> HONEYCOMB cannot be resolved or is not a field.

getActionBar ()setDisplayHomeAsUpEnabled(真)。 - >该方法getActionBar()是未定义的类型DisplayMessageActivity

getActionBar().setDisplayHomeAsUpEnabled(true); -> The method getActionBar() is undefined for the type DisplayMessageActivity.

NavUtils .navigateUpFromSameTask(本); - > NavUtils解决不了

NavUtils.navigateUpFromSameTask(this); -> NavUtils cannot be resolved

有人让我知道该如何解决? 以下是我的输入:

Someone let me know how to solve? Here is what I imported:

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;

非常感谢!

推荐答案

您生成目标未设置为API级别14或更高。这是不是一个错误,请关闭这个问题。

Your build target is NOT set to API Level 14 or higher. This is not a bug, please close this issue.

(在Eclipse:项目=>属性=>安卓)

这篇关于坚持@燮pressLint(&QUOT; NewApi&QUOT;)(developer.android.com/training/basics/firstapp/starting-activity)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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