kotlin FragmentPagerAdapter

package com.jian11058.mykotlindemo.adapter

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentPagerAdapter
import com.jian11058.mykotlindemo.base.BaseFragment

/**
 *   author  : jian11058
 *   time    : 2021/9/15
 *   desc    :
 */
class FragmentAdapter: FragmentPagerAdapter {

    private var fragments:MutableList<BaseFragment>?=null

    constructor(fm: FragmentManager, fragments:MutableList<BaseFragment>):super(fm){
        this.fragments=fragments
    }

    override fun getCount(): Int {
        return fragments?.size!!
    }

    override fun getItem(position: Int): Fragment {
        return fragments?.get(position)!!
    }
}

上一篇:还有人不知道什么是AndroidX的吗?已拿offer入职


下一篇:android----Room数据库的操作(2)