删除r.java,R.java文件删除自身

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.

Here is the menu.xml file code:

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

tools:context="com.andrewq.planets.MainActivity" >

android:icon="@drawable/action_about"

android:title="@string/action_about"

android:orderInCategory="1"

android:showAsAction="always"/>

android:title="@string/action_settings"

android:orderInCategory="100"

app:showAsAction="never" />

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:

android:minSdkVersion="11"

android:targetSdkVersion="19" />

EDIT: 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.

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

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

oR5Fv.png

And the Java code while items are commented out says that it can't

find action_settings or action_about:

FxvLF.png

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

f95QH.png

Now if I take the comment brackets out like so:

CS8O4.png

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

W7qj9.png

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.

EDIT:

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值