Skip to content

Instantly share code, notes, and snippets.

@ibrahim4851
Last active April 17, 2021 10:40
Show Gist options
  • Save ibrahim4851/06ba964e5c7651d1b1c87ebd65fe4fbc to your computer and use it in GitHub Desktop.
Save ibrahim4851/06ba964e5c7651d1b1c87ebd65fe4fbc to your computer and use it in GitHub Desktop.
AdapterInstantiateItem
override fun instantiateItem(container: ViewGroup, position: Int): Any {
layoutInflater = LayoutInflater.from(context)
val view: View = layoutInflater.inflate(R.layout.viewpageritem, container, false)
val imageView: ImageView
val title: TextView
val content: TextView
imageView = view.findViewById(R.id.imageview)
title = view.findViewById(R.id.title)
content = view.findViewById(R.id.content)
Glide.with(context).load(vPagerModel.get(position).image).into(imageView)
title.text = vPagerModel.get(position).title
content.text = vPagerModel.get(position).content
view.setOnClickListener {
val intent = Intent(context, Details::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.putExtra("detail", vPagerModel.get(position).content)
context.startActivity(intent)
}
container.addView(view, 0)
return view
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment