Skip to content

onCreateView is called every time tab is switched #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
giusecapo opened this issue Oct 19, 2017 · 3 comments
Open

onCreateView is called every time tab is switched #8

giusecapo opened this issue Oct 19, 2017 · 3 comments

Comments

@giusecapo
Copy link

giusecapo commented Oct 19, 2017

How can we prevent to lose the current status of the fragment?

I add more details: I'm building an app that has a tinder-like UI with cards. If user scrolls the cards deck, then change fragment, when it comes back the deck is re-load. I need to maintain the position, aka restore view status

@egek92
Copy link

egek92 commented Jun 7, 2018

are you using ViewPager in your fragments? if so you need to setOffscreenPageLimit to how many fragments there is inside your viewpager

@alcntml
Copy link

alcntml commented Sep 10, 2018

Hi,
I'm not using wiewpager, i just run your samplecode. I'm facing the same problem. In your sample code, onCreateView is called everytime but listviews does not recreated. I don't know why listview not recreate but others views that i added are recreates. (I added a textView with random number that i generate in onCreateview. And textview's text changed every time)

@johnkil
Copy link
Contributor

johnkil commented Jun 7, 2019

When switching tabs, fragments are replaced, and the previous fragment putted into backstack with saved state. If you switch back, the fragment is recreated and restores its own state from the saved state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants