I have a gallery I have some pictures in my gallery that there are in the drawable. like this first I put the into in Integer Array like this.
Integer stickers_big[] = { R.drawable.stck1, R.drawable.stck2,...}
and this my adapter :
class stickersAdapter extends BaseAdapter {
Context ctx;
public stickersAdapter(FirstActivity act) {
// TODO Auto-generated constructor stub
this.ctx = act;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return stickers_drawable.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ImageView imageview = new ImageView(ctx);
imageview.setImageResource(stickers_drawable[position].intValue());
imageview.setScaleType(android.widget.ImageView.ScaleType.FIT_XY);
return imageview;
}
}
Now I want to put my images into assets . I do like this , I read my image name and then set it into my imagview. but I JUST read one image name. I dont know how to read the name of all my images and open them.
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ImageView imageview = new ImageView(ctx);
AssetManager assetManager = getAssets();
try {
// get input stream
InputStream ims = assetManager.open("stck1.png");
// create drawable from stream
Drawable d = Drawable.createFromStream(ims, null);
// set the drawable to imageview
imageview.setImageDrawable(d);
}
catch(IOException ex) {
}
return imageview;
}
}
How to read ALL of my images then open them?