Solution 1 :
Brother You can Use a git Library to make Amazing slider
They have all the file that you need
Copy them and use in your project
let me now if it helps you.Or any other help you need.
Solution 2 :
Done…
public void setSlider() {
AssetManager assetManager = getApplicationContext().getAssets();
try {
String[] files = assetManager.list("sliderImages");
List<String> it = Arrays.asList(files);
for (int i = 0; i < it.size(); i++) {
int finalI = i;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
imageView.setImageBitmap(getBitmapFromAssets(it.get(finalI)));
}
}, 2000 * i);
}
} catch (IOException e) {
e.printStackTrace();
}
}
private Bitmap getBitmapFromAssets(String fileName) {
AssetManager assetManager = getAssets();
InputStream istr = null;
try {
istr = assetManager.open("sliderImages/" + fileName);
} catch (IOException e) {
e.printStackTrace();
}
Bitmap bitmap = BitmapFactory.decodeStream(istr);
try {
istr.close();
} catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}
Problem :
I’m trying to make something like Image changer from the images that located in assets/sliderImages folder.
Basically , when I debugging the method, so the it
list equals to the number if the items in the assets/.. folder.
But something is wrong and the Images not shown.
Here is the method to change images.
private ImageView mAuthBackGround;
public void setSlider() {
AssetManager assetManager = getApplicationContext().getAssets();
try {
String[] files = assetManager.list("sliderImages");
List<String> it = Arrays.asList(files);
for (int i = 0; i < it.size(); i++) {
int finalI = i;
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Drawable drawable = Drawable.createFromPath(it.get(finalI));
mAuthBackGround.setImageDrawable(drawable);
}
}, 200 * i);
}
} catch (IOException e) {
e.printStackTrace();
}
}
Comments
Comment posted by Michael
Nope, I don’t wont to user external library for this.
Comment posted by Hamza Regardless
i don’t know how to this asset Manager work.The thing that i m getting is you should try the make Files[] type make Int and store the Interger id of images in this array may it help you.
Comment posted by Hamza Regardless
and you can dierectly pass this image id to the imageView by ” ImageView.setImageResource ( filles [i]);