我是一個機器人的初學者。在嘗試管理活動生命週期的代碼時,我遇到了一件新事物。瞭解@SuppressLint( 「NewApi」)標註
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")
是什麼意思?
相關問題:http://stackoverflow.com/questions/14341042/what-is-better-suppresslint-or-targetapi – laalto