原问题及回答

https://stackoverflow.com/questions/39060458/why-i-am-to-put-images-an-integer-array-in-android/39060675#39060675

 为什么要在Android中将图像放入整数数组?

回答:

如果我们在drawable文件夹中保留的任何资源,android的 SDK会自动为每个资源资源(图像,xml文件等)生成唯一的整数值。

当我们调用 R.drawable.resource_nameR.drawable.image1时,它就会返回一个Integer ID。

这就是为什么在您的代码中需要把R.drawable.image放入Integer Array的原因。

注意:

不仅对于资源(图像,xml等)文件,而且对于在gen文件夹下的类R.java所生成的所有UI组件(布局,按钮,TextView,EditText等)都是返回其唯一的ID 。

  • R.id.ui_component_name用于Button, EditText, TextView, Spinner等),
  • R.layout_layout_name用于(Relative Layout,线性布局等)
  • R.drawable.resource_name用于(Image,custom_views xml等)

 

相关文章:

  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2021-11-27
  • 2022-01-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
  • 2021-08-12
相关资源
相似解决方案