Skip to content

Instantly share code, notes, and snippets.

@lobothijau
Created November 6, 2019 09:16
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/2650bfff6d01ae31bac08a93370e52b9 to your computer and use it in GitHub Desktop.
Save lobothijau/2650bfff6d01ae31bac08a93370e52b9 to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity() {
var sampleImages = arrayOf(
"https://raw.githubusercontent.com/sayyam/carouselview/master/sample/src/main/res/drawable/image_3.jpg",
"https://raw.githubusercontent.com/sayyam/carouselview/master/sample/src/main/res/drawable/image_1.jpg",
"https://raw.githubusercontent.com/sayyam/carouselview/master/sample/src/main/res/drawable/image_2.jpg"
)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val carouselView = findViewById(R.id.carouselView) as CarouselView;
carouselView.setPageCount(sampleImages.size);
carouselView.setImageListener(imageListener);
}
var imageListener: ImageListener = object : ImageListener {
override fun setImageForPosition(position: Int, imageView: ImageView) {
// You can use Glide or Picasso here
Picasso.get().load(sampleImages[position]).into(imageView)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment