https://kotlinlang.org logo
#android
Title
# android
j

Joshua

05/23/2020, 4:35 PM
So I just implemented my drawer and all the menu-items inside of it. I'm able to navigate between my fragments through the menu-items, however, if im in fragment A and click on the menu-item that takes me to fragment A, another view will be created on top of it. So I'm able to create several fragments on top of each other. How can I solve this?
r

Ryan

05/23/2020, 5:11 PM
Do fragment replace instead of add.
a

Archie

05/23/2020, 7:27 PM
@Ryan is correct. Or better yet, try using
Navigation Component
. There are certain things you should know and learn when dealing with `FragmentTransaction`s as you may be doing something you dont expect. If you are not very comfortable with using
FragmentTransaction
, I would highly suggest you try
Navigation Component
instead so you wont deal with
FragmentTransaction
directly.