0

I am trying to use drawer menu for navigation between fragments. I have no problem with this. But I don't find any examples of how to avoid recrating fragment on drawer item click. I need sample like VK app, if I am on page "News feed", I scroll this page a bit down, and then open drawer and select "Messages", do some work there and then open drawer and select "News feed" again, and I see my old news scrolled to the same position.

How can I avoid re-creating fragment with drawer menu?

Neelay Srivastava
  • 1,041
  • 3
  • 15
  • 46
iCaesar
  • 421
  • 2
  • 10
  • 23

1 Answers1

0

First of all see addToBackStack example here and here documentation

Then,why you don't create stack of fragments and every time a fragment is being created add it on your stack.

then in your activity class when user want to go to fragment that before created check if that exist in stack or not.

for this you can push and pop your fragments by specific tag.

Community
  • 1
  • 1
Hoven
  • 563
  • 1
  • 5
  • 24