我有一个 Activityzsmb:materialdrawer
和conductor
class MenuActivity : AppCompatActivity(), GoogleApiClient.OnConnectionFailedListener{
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_menu)
router = Conductor.attachRouter(this, container, savedInstanceState)
if (!router.hasRootController()){
router.setRoot(RouterTransaction.with(HomeController()))
}
}
fun addDrawerItem() {
// not implemented
}
private fun initViews(savedInstanceState: Bundle?) {
toolbarMenu.setTitle(R.string.menu_title)
drawerResult = drawer {
primaryItem(getString(R.string.public_chats)){
identifier = 101
icon = R.drawable.abc_ic_star_black_48dp
onClick(pushController(ChatRoomsController()))
}
primaryItem(getString(R.string.private_chats)){
identifier = 102
icon = R.drawable.abc_ic_star_black_48dp
onClick(openActivity(ChatListActivity::class))
}
}
}
}
class HomeController: Controller() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup): View {
mView = inflater.inflate(R.layout.controller_sign_in, container, false)
val signInWithGoogle = mView.findViewById<Button>(R.id.sign_in_with_google)
signInWithGoogle?.setOnClickListener({
// handle action with drawer here
// mView.addDrawerItem()
})
return mView
}
}
我想Activity
从conductor
. 我正在尝试执行mView.addDrawerItem()
,但此方法在那里不可用。据我所知conductor
,它是一个片段的替代品,fragment
我可以activity
通过interface
. 最好的做法是什么conductor
?