为什么这个R小故障发生(Eclipse Android Java)? [英] Why does this R glitch happen(Eclipse Android Java)?
问题描述
这是继续关闭为什么我的布局无法解决? (Android / Java)(阅读第一个答案的意见),因为我需要发布大量的代码,并且在注释中执行此操作不起作用。
This is a continuation off of Why is my layout unable to be resolved? (Android/Java) (read the comments on the 1st answer) because I need to post a large amount of code, and doing that in a comment doesn't work.
package scouting.form;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
public class Scouting extends Activity {
CheckBox sground,strough,shigh,dground,dtrough,dhigh;
Button logout,clr;
EditText TeamNum;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scouting);
TeamNum=(EditText) findViewById(R.id.TBTeamNum);
sground=(CheckBox) findViewById(R.id.CBSGround);
dground=(CheckBox) findViewById(R.id.CBDGround);
strough=(CheckBox) findViewById(R.id.CBSTrough);
dtrough=(CheckBox) findViewById(R.id.CBDTrough);
shigh=(CheckBox) findViewById(R.id.CBSHigh);
dhigh=(CheckBox) findViewById(R.id.CBDHigh);
logout=(Button) findViewById(R.id.Logout);
logout.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
}
});
clr=(Button) findViewById(R.id.CLREntries);
clr.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
sground.setActivated(false);
strough.setActivated(false);
shigh.setActivated(false);
dground.setActivated(false);
dtrough.setActivated(false);
dhigh.setActivated(false);
}
});
}
@Override public void onBackPressed(){}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_scouting, menu);
return true;
}
}
每行R.xxx.xxx表示R不能被解析为一个变量。
Every line with "R.xxx.xxx" says "R cannot be resolved as a variable".
我尝试干净,因为几乎绝对是eclipse的一个故障,我试图导入android.R,保存和清理,然后取消导入android.R(导入android.R打破一切处理它,但我有意这样做),保存和清理,希望刷新,使故障消失。我也尝试重新启动Eclipse。仍然有这个错误。
I tried doing a clean, and since it's almost definitely a glitch in eclipse, I tried importing android.R, saving and cleaning, then un-importing android.R(importing android.R breaks everything dealing with it, but I did that intentionally), saving, and cleaning, to hopefully "refresh" it to make the glitch go away. I also tried restarting Eclipse. Still having this bug.
推荐答案
我修复了!所以我在原始文件夹中有这个名为Gangam Style.mp3的文件(我没有线索如何到达那里)。我注意到一个错误,说这是一个无效的名字。我进入文件夹并删除该文件,所有的错误都消失了。我想有一个坏的文件类型与Eclipse混乱,无论什么原因,它找不到R。
I fixed it! So I had this file with the name "Gangam Style.mp3" in the raw folder(I have no clue how it got there). I noticed an error saying that was an invalid name. I went into the folder and removed that file, and all of the errors went away. I guess having a bad file kind of messed with Eclipse and for whatever reason, it couldn't find R.
对于任何人谁得到错误,R不能要解决,请确保您没有导入android.R,并确保您的文件夹中没有任何无效的文件名。
To anyone else who gets the error that R can't be resolved, make sure you aren't importing "android.R" and make sure you don't have any file with an invalid name in any of your folders.
这篇关于为什么这个R小故障发生(Eclipse Android Java)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!