public class ImageAdapter extends BaseAdapter {
private File currentDir;
String SCAN_PATH;
File allFiles ;
private Context context;
public Integer[] images={
//I want to load images here
};
public ImageAdapter(Context c){
context = c;
}
@Override
public int getCount() {
return images.length;
}
@Override
public Object getItem(int position) {
return images[position];
}
@Override
public long getItemId(int position) {
return 0;
}
我想加载图片。我只需使用ID添加图像,但我想从内部/ SD卡存储加载图像。 我想知道如何添加图片
答案 0 :(得分:0)
Try loading images into imageview as bitmap
try {
File f=new File(filepath, "imagename.jpg"); // internal or external storage path
Bitmap b = BitmapFactory.decodeStream(new FileInputStream(f));
ImageView img=(ImageView)findViewById(R.id.imgPicker);
img.setImageBitmap(b);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
Hope this may work!