我是 android 编程新手,最近在我的 ubuntu 系统上安装了 Eclipse junos 和 ADT 插件,并下载了 android SDK。在此之后,我创建了一个 android 项目,默认情况下是 hello world 程序,当我运行这个程序时,我收到一个错误“XML 文件中的错误:正在中止构建。”。但我没有编辑任何代码。请帮我解决这个问题。下面是程序。我还收到一个错误,说 R 无法解析为变量。
package com.example.myandroid;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
这是activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>