A
A
aaevseev2020-06-17 15:59:47
Android
aaevseev, 2020-06-17 15:59:47

How to do navigation in android?

There is an application that contains the bottom navigation through the BottomNavigationView.

Alternatively, you can use the Navigation Component . The problem is that this solution does not save the state of the fragments themselves. That is, each transition will re-create all the elements in the layout, which will not be very pleasant for the user. This is especially noticeable when a complex UI or the same webView is displayed on the fragment. You can save the state of the fragment in the viewmodel or use the official Google crutch, but this does not save you from recreating fragments. Without piling up code in navigation, I did not see that it was possible to hide the fragments themselves.

Of course, you can do everything directly through the fragmentManager,but is there any ready-made solution in the form of a library or specific patterns for creating navigation that will take on part of the code so that after a while navigation does not become a sore point of the project, where it will be difficult to maintain and expand.

As I understand it, storing fragments in memory is not the best idea, but I have seen in many applications with bottom navigation, where the transition between tabs occurs in a split second without recreating the fragment.

I looked towards Cicerone, but it was originally written for the MVP architecture and I could not find adequate projects for MVVM with it.

How do you do navigation in your projects and how do you deal with saving a fragment? I will be grateful if you send an example of navigation or an article about this.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question