" ID不能得到解决或不是场"错误?错误、不是、QUOT、ID

2023-09-11 20:34:54 作者:日青良月

我不断收到此错误。如果我只是做 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)