Can anyone tell why this works in Fragment A but n...
# announcements
j
Can anyone tell why this works in Fragment A but not in Fragment B. Fragment A:
Copy code
viewModel.toolbarViewConfig.title.value = "What do you want to do?"
Fragment B:
Copy code
activityViewModel.toolbarViewConfig.title.value = "Make $$$"
More Code Fragment A:
Copy code
val viewModel = ViewModelProvider(activity!!)
    .get(MainActivityViewModel::class.java)

viewModel.toolbarViewConfig.title.value = "What do you want to do?"
viewModel.toolbarViewConfig.isMenuVisible.value = true


return inflater.inflate(R.layout.fragment_home, container, false)
More Code Fragment B:
Copy code
val viewModel = ViewModelProvider(this).get(GoOnlineViewModel::class.java)
val activityViewModel = ViewModelProvider(activity!!).get(MainActivityViewModel::class.java)
val binding = DataBindingUtil.inflate<FragmentSellerGoOnlineBinding>(
    inflater, R.layout.fragment_seller_go_online,
    container, false
).apply {
    this.lifecycleOwner = viewLifecycleOwner
    this.viewModel = viewModel}

activityViewModel.toolbarViewConfig.title.value = "Make $$$"
activityViewModel.toolbarViewConfig.isMenuVisible.value = false

viewModel.navigationCommand.observe(viewLifecycleOwner, Observer {
    when(it) {
        is <http://NavigationCommand.To|NavigationCommand.To> ->
            Navigation.findNavController(requireView()).navigate(it.directions)
    }
})



return binding.root
I'm not able to override the value
viewModel.toolbarViewConfig.title.value
in fragment B
k
$
in strings have a special meaning and have to be escaped