Issue
private void changePicture(int stageIndex){
try{
iv=(ImageView) findViewById(R.id.imageView2);
Picture picture=new Picture();
String v =picture.getPicFileName();
InputStream ims = getAssets().open(v);
Drawable d = Drawable.createFromStream(ims, null);
iv.setImageDrawable(d);
}catch(IOException ex){
return;
}
}
I want to load a list of images from /asset
folder, so I wrote this function, but it doesn't work. Can someone help me?
Solution
if your images are stored in image
folder in assets directory then, the list can be displayed as follows
private List<String> getImage(Context context) throws IOException
{
AssetManager assetManager = context.getAssets();
String[] files = assetManager.list("image");
List<String> it=Arrays.asList(files);
return it;
}
Answered By - arv
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.