如何将图像视图 ID 存储在数组中并在特定图像视图元素上设置图像资源
How To store image view id's in array and set image resource on specific image view element
imgv is a array contain id's of image view
如何将 ImageView ID 存储在数组中并在特定 ImageView 元素上设置图像资源?
您不能在 int 数组上使用 setImageResource 此方法必须在 ImageView 对象上使用
Sets a drawable as the content of this ImageView.
文档中有更多解释 ImageView
简单地说,你可以这样做
int[] array = {R.drawable.imag_view_1,R.drawable.imag_view_3,R.drawable.imag_view_2};
imageView.setImageResource(array[0]);
imgv is a array contain id's of image view
如何将 ImageView ID 存储在数组中并在特定 ImageView 元素上设置图像资源?
您不能在 int 数组上使用 setImageResource 此方法必须在 ImageView 对象上使用
Sets a drawable as the content of this ImageView.
文档中有更多解释 ImageView
简单地说,你可以这样做
int[] array = {R.drawable.imag_view_1,R.drawable.imag_view_3,R.drawable.imag_view_2};
imageView.setImageResource(array[0]);