本文介绍了了解@燮pressLint(" NewApi")注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个机器人的初学者。虽然试图管理活动生命周期的code,我遇到了一个新的东西。

I am an android beginner. While trying a code of managing activity life cycle, I encountered a new thing.

package com.example.activitylaunch;

import android.os.Build;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;

@SuppressLint("NewApi")
public class MainActivity extends Activity {

TextView mTextView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mTextView = (TextView) findViewById(R.id.text_message);

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

@Override
public void onDestroy(){
    super.onDestroy();
    android.os.Debug.stopMethodTracing();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}

我明白了code很好,但它在动作条燮pressLint了一个错误。当我双击它, @燮pressLint(NewApi)正在增加。什么叫 @燮pressLint(NewApi)吗?

I understood the code well, but it gave an error in ActionBar SuppressLint. When I double clicked it, @SuppressLint("NewApi") is being added. What is meant by @SuppressLint("NewApi") here?

推荐答案

@燮pressLint(NewApi)是由Android的皮棉工具注解

@SuppressLint("NewApi") is an annotation used by the Android Lint tool.

林特会告诉你,只要东西在你的code不是最优或可能会崩溃。通过传递 NewApi 在那里,你SUP pressing所有警告,会告诉你,如果你使用后,你的的minSdkVersion

Lint will tell you whenever something in your code isn't optimal or may crash. By passing NewApi there, you're suppressing all warnings that would tell you if you're using any API introduced after your minSdkVersion

请参阅皮棉检查的完整列表 - 包括NewApi - 在这里: http://tool​​s.android.com/提示/皮棉核对

See a full list of Lint checks - including "NewApi" - here: http://tools.android.com/tips/lint-checks

这篇关于了解@燮pressLint(" NewApi")注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 14:03