Hye all,我是android的新手。我想问一下是否可以在gridView中添加驱动器文件夹图像?到目前为止,我已经完成了应用程序,我手动将图像添加到drawable文件夹中。但现在我想加载在线images.Plus我不想添加每个单个图像的URL。我可以添加文件夹路径并让它自动加载带有图像的gridView吗?下面是我的ImageAdapter类,我手动添加图像。
public class ImageAdapter extends BaseAdapter {
private Context mContext;
Bitmap bmImg;
ImageView imageView;
// Keep all Images in array
public Integer[] mThumbIds = {
R.drawable.macro,
R.drawable.macro1,
R.drawable.macro2,
R.drawable.macro3,
R.drawable.macro4,
R.drawable.macro5,
R.drawable.macro6,
R.drawable.macro7,
};
// Constructor
public ImageAdapter(Context c){
mContext = c;
}
@Override
public int getCount() {
return mThumbIds.length;
}
@Override
public Object getItem(int position) {
return mThumbIds[position];
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView = new ImageView(mContext);
imageView.setImageResource(mThumbIds[position]);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(300, 300));
return imageView;
}