title: Reuse Fragment View after return from back stack
body: <p>I have FrameLayout and I'm loading different fragments. For example: fragment with listView and on Item selected load another fragment in the same frame. I'm adding  <code>fragmentTransaction.addToBackStack(null);</code>
  but when I press the back button when I return to fragment with the listview it starts to create all the stuff in the onCreatView and that takes tame to load the images and text again. 
  How can I save that view and when return from the back stack just to load it, not creating it again.</p>
  
  <p>This is my Fragment:</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.fragment_list_cases_atlas, container, false);
      mGridView = (GridView) rootView.findViewById(R.id.gridViewAtlasCases);
  
      mPullToRefreshLayout = new PullToRefreshLayout(container.getContext());
      mPullToRefreshLayout = (PullToRefreshLayout) rootView.findViewById(R.id.ptr_layout);
      ActionBarPullToRefresh.from(getActivity())
              .options(Options.create()
                      // Here we make the refresh scroll distance to 65% of the GridView height
                      .scrollDistance(.65f)
                      // Here we define a custom header layout which will be inflated and used
                      // Here we define a custom header transformer which will alter the header
                      // based on the current pull-to-refresh state
                      .build())
              .allChildrenArePullable()
              .listener(this)
              // Here we'll set a custom ViewDelegate
              .useViewDelegate(GridView.class, new AbsListViewDelegate())
              .setup(mPullToRefreshLayout);
  
      Bundle bundle = this.getArguments();
      if (bundle != null) {
          selectedCatDTO = (CategoryDTO) bundle.get(Constants.BUNDLE_SELECTED_CATEGORY_WAITING);
      }
      ((TextViewAvenirLTStdMedium) rootView.findViewById(R.id.tvSubCategoryTitle)).setText(selectedCatDTO.getName());
      ((TextViewAvenirLTStdLight) rootView.findViewById(R.id.tvSubCategoryCount)).setText("( " + selectedCatDTO.getCount() + " " + getString(R.string.string_cases) + " )");
  
      if (SharedPreferencesManager.getCasesForCategory(getActivity(), String.valueOf(selectedCatDTO.getId())).equals("")) {
          mPullToRefreshLayout.setRefreshing(true);
          final NetworkHandler networkHandler = NetworkHandler.getInstance();
          networkHandler.readCases(new OnCaseTaskComplited(), String.valueOf(selectedCatDTO.getId()));
      } else {
          prepareCategories(SharedPreferencesManager.getCasesForCategory(getActivity(), String.valueOf(selectedCatDTO.getId())));
          setAdapterGridView();
      }
  
      LinearLayout llSubmitAtlas = (LinearLayout) rootView.findViewById(R.id.llSubmitAtlas);
      llSubmitAtlas.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              SubmitCaseWaitingFragment fragmentSubmitCaseWaiting = new SubmitCaseWaitingFragment();
              FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
              fragmentTransaction.addToBackStack(null);
              fragmentTransaction.replace(R.id.content_frame, fragmentSubmitCaseWaiting).commit();
          }
      });
      return rootView;
  }
  
  private void setAdapterGridView() {
      final CasesGridViewAdapter mCustomGridAdapter = new CasesGridViewAdapter(getActivity(), R.layout.cases_gridview, mCases, R.drawable.loading_text);
      mGridView.setAdapter(mCustomGridAdapter);
      mGridView.setOnItemClickListener(new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) {
              Case caseObject = mCustomGridAdapter.getChild(position);
              Bundle bundle = new Bundle();
              bundle.putSerializable(Constants.BUNDLE_SELECTED_CASE_WAITING, caseObject);
              WaitingCaseDetailsFragment fragmentWaitingCaseDetails = new WaitingCaseDetailsFragment();
              fragmentWaitingCaseDetails.setArguments(bundle);
              FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
              fragmentTransaction.addToBackStack(null);
              fragmentTransaction.replace(R.id.content_frame, fragmentWaitingCaseDetails).commit();
          }
      });
  }
  </code></pre>
  
  <p>And this is my GridViewAdapter:</p>
  
  <pre><code>public CasesGridViewAdapter(Context context, int layoutResourceId, List&lt;Case&gt; objects, int defaultImageResId) {
      super(context, layoutResourceId, objects);
      this.layoutResourceId = layoutResourceId;
      mContext = context;
      this.cases = objects;
      this.defaultImageResId = defaultImageResId;
  
      // Get memory class of this device, exceeding this amount will throw an
      // OutOfMemory exception.
      final int memClass = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
  
      // Use 1/8th of the available memory for this memory cache.
      final int cacheSize = 1024 * 1024 * memClass / 8;
      mMemoryCache = new LruCache&lt;String, Bitmap&gt;(cacheSize) {
  
          protected int sizeOf(String key, Bitmap bitmap) {
              // The cache size will be measured in bytes rather than number of items.
              return bitmap.getByteCount();
          }
  
      };
  
      mRequestQueue = Volley.newRequestQueue(context);
      mImageLoader = new ImageLoader(mRequestQueue, new ImageLoader.ImageCache() {
  
          public void putBitmap(String url, Bitmap bitmap) {
              mMemoryCache.put(url, bitmap);
          }
  
          public Bitmap getBitmap(String url) {
              return mMemoryCache.get(url);
          }
      });
  
  
  }
  
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
      View row = convertView;
      Case caseItem = cases.get(position);
  
      if (row == null) {
          LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
          row = inflater.inflate(layoutResourceId, parent, false);
          holder = new ViewHolder();
          holder.imageTitle = (TextView) row.findViewById(R.id.tvGridViewText);
          holder.image = (NetworkImageView) row.findViewById(R.id.ivGridViewImage);
          holder.progressBar = (ProgressBar) row.findViewById(R.id.viewProgressBar);
          row.setTag(holder);
      } else {
          holder = (ViewHolder) row.getTag();
      }
  
      holder.imageTitle.setText(caseItem.getTitle());
      try {
          String key = SomeHelp.getBlobstoreImageUrl(caseItem.getPhotos().get(0).getBlobKeyThumbnail());
          holder.image.setImageUrl(key, mImageLoader);
          holder.image.setDefaultImageResId(defaultImageResId);
      } catch (Exception e) {
          holder.image.setImageResource(R.drawable.no_image_text);
      }
      return row;
  }
  
  static class ViewHolder {
      TextView imageTitle;
      NetworkImageView image;
      ProgressBar progressBar;
  }
  </code></pre>