Issue
I have 4 tabs holding a fragment. When I switch from fragment 2 to any other fragment I want to keep the fragments state (it has input fields for uploading an item to a server).
I have tried using addToBackStack but it would end up with all fragments having it to be able to keep my fragment 2's state.
This is what I want:
Fragment 1 = home
Fragment 2 = upload
Fragment 3 = edit
Fragment 4 = support
2 -> 1 = keep 2's state
2 -> 3 = keep 2's state
1 -> 2 = resume 2's state
3 -> 2 = resume 2's state
1 -> 3 = keep 2's state
3 -> 1 = keep 2's state
etc..
I have over 30 inputfields in upload and I dont want to store all information in SQLite for every time any EditText text changes.
If I use addToBackStack then I can go from home to support to edit and so on. I don't want that! Yelp!
Solution
Maybe not suite for your needs, but if you can, instantiate a fragment only once:
private MyFragment mMyFragment;
private MyOtherFragment mMyOtherFragment;
Init them somewhere and reuse them without instantiate them again
Answered By - Tamás Cseh
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.