ListView 数组适配器错误"None of the following functions can be called with the arguments supplied."

ListView Array Adapter error"None of the following functions can be called with the arguments supplied."

我正在尝试使用 id=lv 的 ListView 创建一个片段,但 ArrayAdapter 似乎不起作用

这是片段代码

class Istoric : Fragment() {
    var array = arrayOf("item1","item2")

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val adapter = ArrayAdapter(this,R.layout.listview_item,array)
    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_istoric, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        val lv1: ListView = view.findViewById(R.id.lv)
        lv1.setAdapter(adapter)
    }
} 

您需要传递上下文而不是 this

val adapter = ArrayAdapter(requireContext(), R.layout.listview_item, array)