Я начинаю андроид. Пробовав код управления жизненным циклом деятельности, я столкнулся с новой вещью.Понимание @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