我正在尝试修改此示例:
http://developer.android.com/resources/tutorials/views/hello-gridview.html
但是我想显示当前存储在List中的Drawables,而不是显示资源图像。
任何人都可以告诉我如何修改
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
};
要显示我的可绘制项目吗?
谢谢!
答案 0 :(得分:1)
你只需改变一些小事。在'imageView.setImageResource(mThumbIds [position]);'你必须用mThumbIds.get(position)替换数组访问器,'mThumbIds.length'变成'mThumbIds.size()'。
这是未经测试的,但我认为这就是你所需要的。