Code example for Fragment

Methods: onActivityCreated, setRetainInstance

0
 
  } 
 
  @Override 
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setRetainInstance(true);
  } 
 
  @Override 
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_assets, container, false);
 
    textViewSelectPhotos = (TextView) view.findViewById(R.id.textViewSelectPhotos);
    gridView = (GridView) view.findViewById(R.id.gridViewAssets);
    emptyView = view.findViewById(R.id.empty_view_layout);
    // gridView.setEmptyView(emptyView); 
 
    Button ok = (Button) view.findViewById(R.id.buttonOk);
    Button cancel = (Button) view.findViewById(R.id.buttonCancel);