Skip to content
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

Reset the view again #11

Open
kkrishnan90 opened this issue Jun 12, 2016 · 1 comment
Open

Reset the view again #11

kkrishnan90 opened this issue Jun 12, 2016 · 1 comment

Comments

@kkrishnan90
Copy link

Hi,
Thanks for such a great library. I am using fragments along with tabs and placing this stepperview in one of the fragments. I would like to know how to reset the entire stepperview once the job is done and the user clicks finish button.

@ser-dev
Copy link

ser-dev commented Apr 17, 2017

Hello,
I'd like to thank you as well @drozdzynski for this great lib 🥇

But I think I'm facing a similar problem as the one reported in this issue.
I have a NavDrawer that handles several fragments. One of the fragments contains the StepperView with a few steps. It works great and looks awesome, but I face one problem: if the user leaves the current fragment and moves to another, and then comes back... the StepperView is not created from scratch. It looks like it saves some state and the initial steps appear collapsed.

Would you know how to reset the whole StepperView to the initial state when moving between fragments?

EDIT:
I found a way (not very beautiful though...) to accomplish the reset when moving to another fragment and coming back -> just removing the fragments which are set into each of the steps:

for(Fragment f:getActivity().getSupportFragmentManager().getFragments()){
            if(f!=null &&
                    f instanceof MyFragment1 || 
                    f instanceof MyFragment2
                getActivity().getSupportFragmentManager().beginTransaction().remove(f).commit();
        }

With that, the StepperView is created and the onCreateView is called for each for the MyFragmentX and they are visible again.

Another possibility that may work is to just restart the whole fragment by detaching and attaching it again:

YourFragmentClass fragment = (YourFragmentClass) 
getFragmentManager().findFragmentById(R.id.your_fragment_container_id)

getFragmentManager().beginTransaction()
                    .detach(fragment)
                    .attach(fragment)
                    .commit();

Second solution from: http://stackoverflow.com/questions/33461560/restart-fragment-class-when-back-button-press

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

No branches or pull requests

3 participants