0

I am using bottom navigation for single activity.

What I'm trying to do is do various screen transitions through the bottom menu (fragment). And we are implementing a function to switch screens without moving the menu on the switched screen.

I've considered using the BottomNavigation Activity provided by Android (probably the JetPack navigation component).

However, I saw that there were many problems with this component. Especially the NavController.

For example, when i switch screens and then come back, i have to manually restore the view state.

Because NavController uses replace() instead of show/hide, so I've been told so

In addition to these problems, using FragmentManager and show/hide is more recommended, is it true?

So I'm currently using setOnNavigationItemSelectedListener, but it's actually more difficult because I'm implementing the screen transition myself.

ybybyb
  • 1,385
  • 1
  • 12
  • 33
  • 2
    Views automatically save and restore their own state as per [Saving View State](https://developer.android.com/guide/fragments/saving-state#view) - you can verify this by looking at any `EditText` with an `android:id`. You'd need to do this anyways to support configuration changes and process death and recreation - it isn't an optional thing you can ignore in any case. – ianhanniballake Jun 10 '21 at 23:14

1 Answers1

1

I would definitely use the provided NavController if I was you.

It has had its issues over the years, some of them which you are describing. Most of these problems were removed in version 2.4.0-alpha01. Version 2.4.0-alpha02 is also out now.

Check out this sample to see the BottomNavigationView in action, together with the new NavController. It is a great starting point for any app.

shko
  • 64
  • 2
  • 20
  • thank you. But the link is an alpha version. In other words, it is a trial version rather than a full version. Is it okay to use it? – ybybyb Jun 11 '21 at 17:52
  • 1
    It should be okay to use it. I have personally used version 2.4.0-alpha02 ever since it came out, and I have not encountered any issues. I think implementing everything from scratch will be more prone to errors – shko Jun 11 '21 at 20:30