为什么该R故障发生(Android版的Eclipse的Java)? [英] Why does this R glitch happen(Eclipse Android Java)?

查看:150
本文介绍了为什么该R故障发生(Android版的Eclipse的Java)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个延续了的<一个href=\"http://stackoverflow.com/questions/13224983/why-is-my-layout-unable-to-be-resolved-android-java\">Why是我的布局不能得到解决? (Android版/ JAVA)(读一号答案评论),因为我需要张贴大量的code,而这样做的评论是行不通的。

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的。仍然有这个bug。

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故障发生(Android版的Eclipse的Java)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆