Android Fragments 未解析的引用:碎片

nwsw7zdq  于 2022-12-23  发布在  Android
关注(0)|答案(1)|浏览(196)

我在我的kotlin代码中遇到了一些错误。代码如下:

'''package com.mohamed.focuscounter

import android.os.Bundle
import androidx.fragment.app.Fragment                        //(line4)
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup'''

'''class AvailableFragment : Fragment() {                       //(line 9)
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_available, container, false)
    }
}'''

 The Errors encountered is as follows:
   1.unresolved reference:fragment (line 4)
   2.unresolved reference:Fragment (line 9)

任何帮助都将不胜感激

ijxebb2r

ijxebb2r1#

确保应用build.gradle文件中具有Fragment的依赖项

implementation "androidx.fragment:fragment-ktx:1.5.5"

相关问题