" i found this code from a website"
Copying ans pasting code is never the way to go. Learn how/why it works, and create your own code that uses the found code as a reference.
" try to slide image it shows image not available i."
Without running your program, because I don't have the image resources, I could see this problem. Your code, uses a getResource()
, which will look for images in the class path.
URL url = ImageSlider.class.getResource(name);
The path name
That is passed to it requires a class path reference. But what you are doing is passing an absolute path
list.add("E:\\SOFTWARE\\TrainPIS\\res\\drawable\\yellow.png");
...
String name = "images/" + list.get(index);
The way this code is set up, it looks like the producer of the code had their images
folder inside the src
and just passed/added the image file name e.g. "image.png"
list.add("image.png");
You your file structure should look like
ProjectRoot
src
images
image.png
NOTE: This is all just an educated guess. Try it out (change the image location and the paths. Also if it doesn't work, try to add a /
before "images/"
→ "/images/"