title: Implement some functionality like in Instagram android app
body: <p>There are two things which I like on the Instagram for Android app and I'd like to implement them in my app.</p>
  
  <p><strong>1. Infinite go back in history of fragments</strong></p>
  
  <p>If you tap on a user, you can see his details, taping on followers will return a list of followers, pressing on another user will show his details... and so on. Basically you can do this thing for many times BUT when you go back everything is instant without loading. How can this be implemented? My initial thought was to have only one activity with a top actionbar and  for the rest use fragments (one fragment for user details, one fragment for users list) and so on. The problem is I can't think of a good way to allow going back in history. The only way I can see is by caching all the data (user data / list adapters) is an ArrayList so when the user presses back, take the last item from the list and instantiate the fragment. Is there a better way of doing it ? I'm thinking I could start a new activity for each user interaction and them when the user presses back, simply finish the current one. My only worry in this case would be running out of memory. Is there a way to cache fragments with their state ?</p>
  
  <p><strong>2.GridView inside ScrollView</strong></p>
  
  <p>On user details there are two main layouts: a layout with user details and a gridview of images. When the user scrolls, at the scroll's end, the gridview gets new set of items (load as you scroll). While I know how to implement load as I scroll for the gridview, I don't know how to add the gridview inside a scrollview and keep listening for scroll events</p>
  
  <p><img src="https://i.stack.imgur.com/IOe1A.png" alt="enter image description here"></p>