如何从 MvpActivity 访问 MvpFragment。
片段,使用当前代码 -
class Fragment1: MvpFragment<IView, Presenter>(){
override fun createPresenter(): Presenter {
return Presenter(getActivity().getApplicationContext())
}
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater!!.inflate(R.layout.activity_main, container, false)
}
}
活动是——
class MainActivity : MvpActivity<IView, Presenter>(), IView {
override fun createPresenter(): Presenter {
return Presenter(getApplicationContext())
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
fun create_fragment(view: View){
var frgmnt = getFragmentManager().beginTransaction()
frgmnt.replace(R.id.containerZ, Fragment1())
}
}