I use Navigation Architecture in my project and I have some fragments as destinations. Its host is my MainActivity. Now I want to call one of my destinations' methods from the host (MainActivity). What should I do?
You need to get the navController and then call the destination fragment by action I'd or destination I'd as defined in your navigationgraph.xml
Refer Android doc for navigating to destination section: https://developer.android.com/guide/navigation/navigation-getting-started#java
//Sample code
Navigation.findNavController(view).navigate(R.id.viewTransactionsAction);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.