Note that there are some explanatory texts on larger screens.

plurals
  1. POStuck with @SuppressLint("NewApi") (developer.android.com/training/basics/firstapp/starting-activity)
    primarykey
    data
    text
    <p>I'm a begginer with Android and currently stuck with the lession: <a href="http://developer.android.com/training/basics/firstapp/starting-activity.html">http://developer.android.com/training/basics/firstapp/starting-activity.html</a></p> <p>In the part <strong>Create the Second Activity</strong>, when I try to use the code:</p> <pre><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 &gt;= 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); } } </code></pre> <p>I get the error below:</p> <p><strong>@SuppressLint("NewApi")</strong> -> The attribute value is undefined for the annotation type SuppressLint.</p> <p>if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.<strong>HONEYCOMB</strong>) -> HONEYCOMB cannot be resolved or is not a field.</p> <p><strong>getActionBar</strong>().setDisplayHomeAsUpEnabled(true); -> The method getActionBar() is undefined for the type DisplayMessageActivity.</p> <p><strong>NavUtils</strong>.navigateUpFromSameTask(this); -> NavUtils cannot be resolved</p> <p>Someone let me know how to solve? Here is what I imported:</p> <pre><code>import android.app.Activity; import android.os.Build; import android.os.Bundle; import android.view.MenuItem; </code></pre> <p>Many thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload