Skip to content

Instantly share code, notes, and snippets.

@lobothijau
Last active November 6, 2019 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lobothijau/2fa7bd879c71e6530ea3a8175f4097d5 to your computer and use it in GitHub Desktop.
Save lobothijau/2fa7bd879c71e6530ea3a8175f4097d5 to your computer and use it in GitHub Desktop.
public class MainActivity extends AppCompatActivity {
CarouselView carouselView;
int[] sampleImages = {R.drawable.image_1, R.drawable.image_2, R.drawable.image_3, R.drawable.image_4, R.drawable.image_5};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
carouselView = findViewById(R.id.carouselView);
carouselView.setPageCount(sampleImages.length);
carouselView.setImageListener(imageListener);
}
ImageListener imageListener = new ImageListener() {
@Override
public void setImageForPosition(int position, ImageView imageView) {
imageView.setImageResource(sampleImages[position]);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment