【问题标题】:Unresolved reference: showToast in Kotlin未解决的参考:Kotlin 中的 showToast
【发布时间】:2020-11-26 02:13:02
【问题描述】:

我正在尝试在 android 中使用 tensorflow lite 版本。构建项目时出现以下错误。请帮忙。

错误

Unresolved reference: showToast

代码

override fun onConfigureFailed(session: CameraCaptureSession) {
                    this@MainActivity.showToast("Failed")

【问题讨论】:

    标签: android tensorflow kotlin


    【解决方案1】:

    使用此行显示 toast

    Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show()
    

    【讨论】:

      【解决方案2】:

      您也可以使用此行在片段中显示 toast。

      Toast.makeText(requireContext(), "Authentication failed.", Toast.LENGTH_SHORT).show()
      

      【讨论】:

        猜你喜欢
        • 2018-10-25
        • 1970-01-01
        • 1970-01-01
        • 2021-11-02
        • 2021-10-29
        • 2018-10-16
        • 2023-03-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多