R.java文件删除自身 [英] R.java file deleting itself

查看:168
本文介绍了R.java文件删除自身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个轻微的问题。当我将项目添加到menu.xml文件文件,在根文件夹中的文件R.java不会产生。我用同样的code之前没有出现问题。我使用Eclipse在Windows 7。

I have a slight issue. When I add items to the menu.xml file, the R.java file in the gen folder does not generate. I've used the same code before and no problems have arisen. I am using Eclipse with the ADT plugin on Windows 7.

下面是menu.xml文件文件code:

Here is the menu.xml file code:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.andrewq.planets.MainActivity" >

    <item android:id="@+id/action_about"
        android:icon="@drawable/action_about"
        android:title="@string/action_about"
        android:orderInCategory="1"
        android:showAsAction="always"/>

    <item android:id="@+id/action_settings"
        android:title="@string/action_settings"
        android:orderInCategory="100"
        app:showAsAction="never" />

</menu>

这是MainActivity.java使用code:

And here is the code used in MainActivity.java:

//Method used to inflate the menu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

//Method used to add items to the menu
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    super.onOptionsItemSelected(item);

    switch (item.getItemId()) {
        case R.id.action_about:
            aboutMenuItem();
            break;
        case R.id.action_settings:
            Intent intent = new Intent(getApplicationContext(), Settings.class);
            startActivity(intent);
            break;
    }

    return super.onOptionsItemSelected(item);
}

仅供参考 - 下面是一些舱单信息:

FYI -- Here is some Manifest information:

<uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="19" />

编辑:这个问题似乎当项目被添加到menu.xml文件的文件产生。如果我删除的项目,它只是说,它无法找到 action_about action_settings 而当项目是那里的R.java文件中消失。

The problem seems to arise when the items are added to the menu.xml files. If I delete the items, it just says it can't find action_about or action_settings whereas when the items are there the R.java file disappears.

编辑#2:这里是code设置的一些截图:

EDIT #2: Here are some screenshots of code setup:

下面是XML code与项目的图片注释。

Here is a picture of the XML code with the items commented out.

和Java code,而项目被注释掉说,它不能
  找到action_settings或action_about:

And the Java code while items are commented out says that it can't find action_settings or action_about:

最后,错误输出,而项目被注释掉:

And finally, the errors output while items are commented out:

结果
结果

现在,如果我把注释括号出来,像这样:

Now if I take the comment brackets out like so:

下面的错误引起的,可似乎没有解决:

The following errors arise which can't seem to be solved:

结果
我希望这可以帮助别人解决我的问题。我以前从来没有这个问题。


I hope this can help someone solve my problem. I've never had this problem before.

谢谢,结果
安德鲁

Thanks,
Andrew

推荐答案

这不是删除自身,它没有得到对你所做的更改产生的。所以,我建议你清理项目,重建它,如果它仍然显示的问题,转到控制台并检查问题。如果没有显示存在,未解决的问题查看,并检查它。当然,它会提示一些错误。请看一看错误日志了。

It's not deleting itself, it's not getting generated for the changes that you've made. So I suggest you clean the project, rebuild it, and if it still shows issues, go to the console and check the issues. If nothing shows there, open problems view and check it. Surely it will suggest some errors. Please take a look at error log too.

编辑:
如果您使用的是API 11或以下,从菜单中删除showAsAction =从不或清单文件分钟SDK版本设置为11。

remove showAsAction="never" from menu if your using API 11 or below or set min SDK version to 11 in manifest file.

这篇关于R.java文件删除自身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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