@SuppressLint("NewApi") アノテーションを理解する 質問する

@SuppressLint(

私は Android 初心者です。アクティビティのライフサイクルを管理するコードを試しているときに、新しいことに遭遇しました。

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;
}

}

コードはよく理解できましたが、ActionBar SuppressLint でエラーが発生しました。ダブルクリックすると、@SuppressLint("NewApi")が追加されています。ここはどういう意味ですか@SuppressLint("NewApi")?

ベストアンサー1

@SuppressLint("NewApi")Android Lint ツールで使用される注釈です。

Lintは、コードが最適でなかったりクラッシュする可能性がある場合に通知します。NewApiそこにパスすることで、コードがリリースされた後に導入されたAPIを使用しているかどうかを示すすべての警告を抑制します。minSdkVersion

「NewApi」を含む Lint チェックの完全なリストについては、こちらをご覧ください。http://tools.android.com/tips/lint-checks

おすすめ記事