Display a gallery of images that are stored as Drawables in a List
I am trying to modify this example:
http://developer.android.com/resources/tutorials/views/hello-gridview.html
But instead of displaying images that are resources, I want to display Drawables that I currently am storing in a Lis开发者_如何学编程t.
Can anyone instruct me on how I would modify
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
};
To display my drawable items instead?
Thanks!
You only have to change a few minor things. In 'imageView.setImageResource(mThumbIds[position]);' you have to replace the array accessor by mThumbIds.get(position) and 'mThumbIds.length' becomes 'mThumbIds.size()'.
This is untested, but I think that is all you need.
精彩评论