“类BaseActivity <T需要一个类型参数,T:BasePresenter <*>”此错误,我该怎么办?

时间:2019-12-26 11:15:30

标签: android generics kotlin

这是我的BaseActivity, 当我将此活动的实例放在另一个类中时,它给了我下面的错误。

  

BaseActivity类应该有一个类型参数

有人知道吗,或者有人可以帮忙解决此问题吗?

abstract class BaseActivity<T : BasePresenter<*>>: AppCompatActivity(){


      var presenter: T? = null
          protected set

       var view: View? = null
          protected set


      var button_backhome: ImageButton? = null

      public override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          presenter = addPresenter()
          view = addView()
          onPresenterCreated(presenter!!)
      }

      override fun onDestroy() {
          super.onDestroy()
          if (presenter != null) {
              presenter!!.detachView()
          }
      }


      abstract fun addPresenter(): T

      abstract fun addView(): View?

      abstract fun onPresenterCreated(presenter: T)

     companion object {
          protected var back_pressed: Long = 0
      } }


0 个答案:

没有答案