R 1不能被解析为一个变量日食的android [英] R cannot be resolved to a variable eclipse android
本文介绍了R 1不能被解析为一个变量日食的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试过在这个网站所有的答案present。删除了进口android.R;线。即使这样我每次运行我的项目时,它说:你的项目中包含的错误,运行应用程序之前解决这些问题。我工作的Eclipse。当我创建我有2个错误,这不能不遇到一个新的Android应用程序项目R不能解析为一个变量。这里是我的code为MainActivity.Java
包com.example.myfirstapp;
//进口android.R;
进口android.app.Activity;
进口android.os.Bundle;
进口android.view.Menu;
类MainActivity延伸活动{ @覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
setContentViewq(R.layout.activity_main);
} @覆盖
公共布尔onCreateOptionsMenu(菜单菜单){
//充气菜单;如果是present这增加了项目操作栏。
。getMenuInflater()膨胀(R.menu.main,菜单);
返回true;
}}
解决方案
只是试试这个在您的进口
进口your_packgae_name.R;
I already tried all the answers present in this website. Deleted the "import android.R;" line. Even then every time I run my project it says "Your project contains errors, fix them before running your application". I'm working on Eclipse. As soon as I create a new android application project I am encountered with 2 errors which say "R cannot be resolved to a variable". Here's my code for MainActivity.Java
package com.example.myfirstapp;
//import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentViewq(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;
}
}
解决方案
just try this at your imports
import your_packgae_name.R;
这篇关于R 1不能被解析为一个变量日食的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文