<How to navigate to another activity based on view...
# stackoverflow
r
How to navigate to another activity based on viewmodel's logic, with view binding / MVVM? I have: MainActivity MainFragment MainViewModel SecondActivity ThirdActivity I have a button in fragment_main.xml. I can easily pass it android:onClick="navigate" and have the function navigate() in MainActivity create an intent and start SecondActivity like so: fun navigate(v: View) { intent = Intent(this, SecondActivity::class.java) startActivity(intent) } But what if I want the button to navigate to a different activity (ThirdActivity) if a bool is true? This is...