【问题标题】:What is the kotlin version of getLifecycle()?getLifecycle() 的 kotlin 版本是什么?
【发布时间】:2019-12-12 11:25:31
【问题描述】:

我想从我想要在 Kotlin 中的活动中调用“Flutter.createView(...)”。目前在 java 中它工作正常,但在将 java 代码转换为 Kotlin 后,它显示未解析的引用。

 val flutterView = Flutter.createView(
                this@TempFlutterBeginActivity,
                getLifecycle(),
                "splashRoute"
        )

【问题讨论】:

    标签: android kotlin flutter


    【解决方案1】:

    我猜这只是 kotlin 中的 lifecycle

    参考文章:Add Flutter to existing app

    根据文章:

    //Import as a view
    val flutterView = Flutter.createView(
        this@FlutterViewActivity,
        lifecycle, null
    )
    
    addContentView(flutterView, FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT))
    
    //Import as a fragmentval tx = supportFragmentManager.beginTransaction()
    tx.replace(R.id.someContainer, Flutter.createFragment(null))
    tx.commit()
    

    【讨论】:

      猜你喜欢
      • 2017-01-19
      • 2018-08-17
      • 1970-01-01
      • 2020-11-30
      • 2013-11-25
      • 1970-01-01
      • 2010-11-22
      • 1970-01-01
      • 2011-04-30
      相关资源
      最近更新 更多