I need to show an image for 1 second, at the end of that time make it invisible for 1 second, and at the end of the time again to show again, because I walk a list and no longer it displays me the following pictures.
But my code only shows me the image by 1 second, but the following images doesn't show them me.
This my code:
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
private void showNextImage() {
// loads the image at position currentPosition
final Bits item = L.get(currentPosition);
imageBit.setImageBitmap(BitmapFactory.decodeFile(item.getbImage()));
handler.postDelayed(new Runnable() {
@Override
public void run() {
imageBit.setImageBitmap(BitmapFactory.decodeFile(item.getbImage()));
}
},1000);
handler.postDelayed(new Runnable() {
@Override
public void run() {
nameBit.setText(item.getbText());
imageBit.setVisibility(View.GONE);
}
},1000);
currentPosition++; // updates the current position
if (L.size() > currentPosition) { // more images to show?
// loads the next image after some delay
handler.postDelayed(new Runnable() {
@Override
public void run() {
showNextImage();
}
}, 1000); // in millis, 1000 for one second delay
}
}