" ID不能得到解决或不是场"错误? [英] "id cannot be resolved or is not a field" error?

查看:148
本文介绍了" ID不能得到解决或不是场"错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到此错误。如果我只是做 ID 字段?

I keep getting this error. Should I just make id a field?

我的code是:

public void onCreate(Bundle icicle) 
{
    super.onCreate(icicle);
    setContentView(R.layout.main);
    ImageView mainimage = (ImageView) findViewById(R.id.mainanim);
    mainimage.setBackgroundResource(R.anim.mainanim);
    mainanimation = (AnimationDrawable) mainimage.getBackground();
}

你解决这个问题究竟如何?

How exactly do you fix this?

推荐答案

不要修改R类。该错误意味着有什么语法错误你的XML布局和R不能自动生成。试看看那里,如果任何发布XML code,你是不知道,。

Do not modify the R class. The error means there's something syntactically wrong with your XML layouts and R cannot be auto-generated. Try looking there and post the xml code you're not sure about, if any.

编辑:另外:从进口文件顶部删除进口android.R(如果有)

Edit : also: remove "import android.R" from imports at top of file (if there)

这篇关于" ID不能得到解决或不是场"错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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