How to load a list of images from assets in Android
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;
}
Step 1: Create a List<String> listPhoto
Step 2: Create Array String
private String [] images;
Step 2: Create function getData()
private void getData(){
try {
images =getAssets().list("image");
} catch (IOException e) {
e.printStackTrace();
}
listPhoto = new ArrayList<String>(Arrays.asList(images));
}
No comments:
Post a Comment