其他分享
首页 > 其他分享> > kotlin FragmentPagerAdapter

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)!!
    }
}

标签:FragmentPagerAdapter,androidx,kotlin,app,jian11058,import,fragments
来源: https://blog.csdn.net/jian11058/article/details/120313781