Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class OnBoardingAdapter(val context : Context, val onBoardingItem: List<OnBoardingItem>) : PagerAdapter(){
- override fun instantiateItem(container: ViewGroup, position: Int): Any {
- val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
- val layoutScreen: View = inflater.inflate(R.layout.item_onboarding, null)
- val img = layoutScreen.findViewById<ImageView>(R.id.img_on_boarding)
- val desc = layoutScreen.findViewById<TextView>(R.id.tv_desc_on_boarding)
- img.setImageResource(onBoardingItem[position].image!!)
- desc.text = onBoardingItem[position].description
- container.addView(layoutScreen)
- return layoutScreen
- }
- override fun getCount(): Int {
- return onBoardingItem.size
- }
- override fun isViewFromObject(view: View, o: Any): Boolean {
- return view === o
- }
- override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
- container.removeView(`object` as View)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement