首页 > 其他 > 详细

fragment不适用binding的加载视图方法

时间:2021-05-28 11:35:31      阅读:17      评论:0      收藏:0      [点我收藏+]
abstract class BaseFragment :Fragment(){

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val rootView = layoutInflater.inflate(getResourcesId(), container, false)
        //初始化控件字段
        initView(rootView)
        return rootView
    }

    open fun initView(rootView: View){//不添加open不能被重写
        
    }

    abstract fun getResourcesId(): Int//加上abstract表示要子类实现
}

 

fragment不适用binding的加载视图方法

原文:https://www.cnblogs.com/--here--gold--you--want/p/14820881.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!