我真的没有进一步了解这个,请看一看: 首先我从基础适配器中得到一个整数(比如“R.drawable.sic_pre”)
ImageAdapter imad = new ImageAdapter(getBaseContext());
并传递给下一个Activity
startActivity((new Intent(getBaseContext(),Card.class)).putExtra("draw", imad.mTlist.get(position)));
并尝试设置资源
Bundle extras = getIntent().getExtras();
ImageView sel = (ImageView)findViewById(R.id.selected);
Integer src = extras.getInt("draw");
sel.setImageResource(src);
setContentView(R.layout.activity_card);
有人知道哪里出了问题吗? 我无法为 ImageView 设置任何资源
ImageView sel = (ImageView)findViewById(R.id.selected);
sel.setImageResource(R.drawable.sic_pre);
也行不通...
顺便问一下,是否可以从与 Integer 相同的字符串中获取此“R.drawable.sic_pre”? (希望它是可以理解的)
到目前为止的问候和感谢
最佳答案
您应该在尝试findViewById
之前调用setContentView
关于Android - 传递图像资源整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20722844/