Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] java – How to make image slider from assets images

Posted on November 14, 2022

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.

Here is the link of slider

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.

READ  [ANSWERED] java - I'm having an error creating an registration using Firebase My app is actually running but when I pressed on register button It keep on showing fail
Powered by Inline Related Posts

Comment posted by Hamza Regardless

and you can dierectly pass this image id to the imageView by ” ImageView.setImageResource ( filles [i]);

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress