android - 显示存储为列表中的可绘制对象的图像库

标签 android

我正在尝试修改这个例子:

http://developer.android.com/resources/tutorials/views/hello-gridview.html

但是我不想显示作为资源的图像,而是想显示我当前存储在列表中的可绘制对象。

任何人都可以指导我如何修改

 private Integer[] mThumbIds = {
         R.drawable.sample_2, R.drawable.sample_3,
         R.drawable.sample_4, R.drawable.sample_5,
         R.drawable.sample_6, R.drawable.sample_7,
         R.drawable.sample_0, R.drawable.sample_1,
         R.drawable.sample_2, R.drawable.sample_3,
         R.drawable.sample_4, R.drawable.sample_5,
         R.drawable.sample_6, R.drawable.sample_7,
         R.drawable.sample_0, R.drawable.sample_1,
         R.drawable.sample_2, R.drawable.sample_3,
         R.drawable.sample_4, R.drawable.sample_5,
         R.drawable.sample_6, R.drawable.sample_7
 };

改为显示我的可绘制项目?

谢谢!

最佳答案

你只需要改变一些小的东西。在 'imageView.setImageResource(mThumbIds[position]);'您必须用 mThumbIds.get(position) 替换数组访问器,并且“mThumbIds.length”变为“mThumbIds.size()”。

这是未经测试的,但我认为这就是您所需要的。

关于android - 显示存储为列表中的可绘制对象的图像库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2798710/

相关文章:

android - 用于报告错误消息、崩溃、异常的库

android - 带有 SnapHelper 的 RecyclerView,项目在 scrollToPosition 之后不被捕捉

java - android中sha256哈希计算错误

android - Bottomsheetbehavior 为 Bottom Sheet 的顶部增加了额外的空间

android - 如何开始 Activity 和结束之前启动的所有其他 Activity

android - ImageView 缩放 : fix height variable width with maxWidth

java - 我如何使用 String 变量而不是在 android 中使用 R.id.webview1

android - 我的 Android 应用程序的 fragment 或 Activity

android - 运行配置的目标选项卡中缺少 AVD

php - 从 Android 应用程序上传多个图像到服务器