Ask Your Question
3

How can I redraw NavGraph fragments using setGraph() when I am unable to do so?

asked 2023-06-26 11:37:25 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2023-06-26 11:43:01 +0000

nofretete gravatar image

If you are unable to redraw NavGraph fragments using setGraph(), you may try one or more of the following solutions:

  1. Use Navigation Action: You can create a navigation action to navigate to the fragment you want to display and call the action using Navigation.findNavController(view).navigate(actionId).

  2. Use FragmentManager: You can use FragmentManager to replace the current fragment with the target fragment.

  3. Use Dynamic Feature Module: If you have implemented your app with dynamic feature modules, you can use them to load new content without having to redraw the entire NavGraph.

  4. Use LiveData: LiveData can help you update the UI every time the data changes. You may set up a LiveData observer in each of the fragments, and whenever you need to redraw the fragments, you can update the LiveData values.

  5. Use ViewModels: You can store the state of the app in ViewModels and use them to redraw the fragments whenever necessary.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-26 11:37:25 +0000

Seen: 10 times

Last updated: Jun 26 '23