I recently started the learning process of creating android apps, I am using IntelliJ IDEA 13.1.1 and I am following this tutorial of adding action bar buttons and I am getting the error cannot resolve symbol navutils
. I have searched online and came across couple of stackoverflow posts (1 and 2) and in those post they seem to be talking about fixing the problem via build.gradle
which i have no idea what it is and cant seem to find this file anywhere.
here is my DisplayMessageActivity.java
code, so far the app seems to be working just fine, i am able to post the text and see it but this action bar button is driving me crazy.
package com.example.My_First_App;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.TextView;
public class DisplayMessageActivity extends Activity {
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display_message);
// Get the message from the intent
Intent intent = getIntent();
String received_message = intent.getStringExtra(MyActivity.SOME_MESSAGE);
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(received_message);
// Set the text view as the activity layout
setContentView(textView);
// Make sure we're running on Honeycomb or higher to use ActionBar APIs
if (Build.VERSION.SDK_INT >= 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);
}
}
I will really appreciate any help in this matter as i am stuck and cant move forward with the tutorial.