Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save basxto/2d8994788ff03499d7fee70095db9bc4 to your computer and use it in GitHub Desktop.
Save basxto/2d8994788ff03499d7fee70095db9bc4 to your computer and use it in GitHub Desktop.
simplified and hopefully fixed
const int last = pics_array.length - 1;
// this method gets called when the forward button got clicked (for testing)
public void go (View view) {
index++;
if(index > last)//out of bounds
index = 0;//jump to beginning
default_Pic.setImageResource(pics_array[index]);
}
// this method gets called when the back button got clicked (for testing)
public void back (View view) {
index--;
if(index < 0)//out of bounds
index = last;//jump to end
default_Pic.setImageResource(pics_array[index]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment