我所有的图像都存储在可绘制的文件夹中。我希望看到一些图像的图库视图。用字符串数组设置图库[图像名称]
我想要的图像的名称是在一个字符串数组中。
我可以通过图库视图来显示这些图像吗?
我发现代码在下面,这里的图像是一个整数。
我可以使用字符串数组吗?
public class ImageAdapter extends BaseAdapter {
private Context context;
public ImageAdapter(Context context){
this.context = context;
}
public int getCount() {
return pics.length;
}
public Object getItem(int arg0) {
return null;
}
public long getItemId(int position) {
return 0;
}
public View getView(int arg0, View arg1, ViewGroup arg2) {
ImageView iv = new ImageView(context);
iv.setImageResource(pics);
iv.setScaleType(ImageView.ScaleType.FIT_XY);
iv.setLayoutParams(new Gallery.LayoutParams(150,120));
iv.setBackgroundResource(imageBackground);
return iv;
}
}
我在代码中看不到任何字符串数组。无论如何,你应该添加一个构造函数,它接收一个字符串数组,然后使用[this link](http://stackoverflow.com/a/3044081/896038) – 2013-04-20 15:45:39