我最近开始了创建 Android 应用程序的学习过程,我正在使用 IntelliJ IDEA 13.1.1,我正在关注这个 tutorial添加操作栏按钮时出现错误 cannot resolve symbol navutils
。我在网上搜索并遇到了几个 stackoverflow 帖子( 1 和 2 ),在那些帖子中,他们似乎在谈论通过 build.gradle
解决问题,我不知道是什么它是而且似乎无法在任何地方找到这个文件。
这是我的 DisplayMessageActivity.java
代码,到目前为止,该应用似乎运行良好,我可以发布文本并查看它,但这个操作栏按钮让我抓狂。
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);
}
}
我真的很感激在这件事上的任何帮助,因为我被困住了,无法继续学习教程。
最佳答案
我觉得你没了
import android.support.v4.app.NavUtils;
关于java - 创建第一个 Android 应用程序并停留在无法解析符号 navutils,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23467112/