我有一个基础抽象类:
abstract class BaseFragment<T : BasePresenter> : Fragment(){
protected var presenter : T? = null
abstract fun providePresenter() : T
abstract fun getLayoutId() : Int
abstract fun onCreate()
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val root = inflater?.inflate(getLayoutId(), container, false)
presenter = providePresenter()
return root
}
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
onCreate()
}
}
我在JAVA中的代码:
//JAVA
private ArrayList<BaseFragment> fragments;
我怎样才能使用Kotlin?代码吼叫不工作
//Kotlin
val tabs = ArrayList<BaseFragment>() //error: One type argument expected for class BaseFragment<T : BasePresenter> : Fragment
答案 0 :(得分:2)
您需要为T
val tabs = ArrayList<BaseFragment<SomePresenterType>>()