下面的代码给了我一个错误这段代码为什么给我一个错误?
public class SuperImage3Activity extends Activity
{
ImageView image1, image2;
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
image1 = (ImageView)findViewById(R.drawable.sourceimage1); // error here
image2 = (ImageView)findViewById(R.drawable.sourceimage2); // error here
}
我的确创建了一个名为绘制和放置sourceimage1.jpg和sourceimage2.jpg目录中的目录。
通过Eclipse中给出的建议是,
“作为ADT 14时,资源领域(如哆啦A梦)不再常量库中的对象定义时, 这是必要的,使库项目可重复使用而无需重新编译它们。这一
一个后果是,你不能再在switch语句中使用的字段directinly。 您必须使用的if-else链,而不是 “
findViewyId表示XML布局中的控件ID,因此您必须给出控件的标识而不是它的iamge资源。谢谢 – SALMAN
http://www.higherpass.com/Android/Tutorials/Working-With-Images-In-Android/你可以看看这个例子 – SALMAN
而不是评论你自己的答案,考虑修改答案主体。 –