简体   繁体   中英

Navigation Architecture Component: How to use same Fragment while navigation

I have 3 fragments navigation each of them by 'Navigation.navigate' making network API to reload and viewpager to set again. I wanted to use the same fragment as it is, which was open already.

I am using the "Navigation Architecture Component", and I am using Navigation.navigate method

If you create your fragment each time a navigation happens you can instead use show() and hide() methods of the fragment, so whenever one of them is the visible show it and hide the other two and another way around. But if your problem is reloading data maybe you should consider other options. Like using ViewModel to store the data of the fragment. please provide more info and publish your code so we can help you better.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM