【发布时间】:2013-10-20 17:27:38
【问题描述】:
我是安卓应用开发的新手,
我刚刚创建了一个简单的android项目,但是当它创建时显示错误。
当我按下 control shift +o 时“R 无法解析为变量”
android.R 自动添加到我的代码中,但现在它显示此错误
“activity_main 无法解析或不是字段”
这是这个项目的代码
package com.php.helloworld;
import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@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;
}
}
当我试图写下这一行时
导入 com.php.helloworld.R 它显示“无法解析导入 com.php.helloworld.R”
我的xml文件也没有问题,gen文件夹中也没有文件 有人可以帮我解决这个问题
【问题讨论】: