title: Set a different layout in Fragment's onResume() method
body: <p>I have a situation where I need to set different layouts for the fragment upon returning from an Activity that does some modifications to that database.</p>
  
  <p>How do I set a different layout for the fragment in the onResume() method of that fragment?</p>
  
  <p>I basically need to copy exactly the same code to the onResume method, but the problem is with this part of the code, I can't understand how I can implement it in the on onResume() method : </p>
  
  <pre><code>rootView = inflater.inflate(R.layout.expandable_list, container, false);
  </code></pre>
  
  <p>Here is the code for the OnCreateView method: </p>
  
  <pre><code>@Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          context = getActivity().getApplicationContext();
  
          dataSource = new ExpensesDataSource(context);
          dataSource.open();
  
          //if Expenses dataSource is not empty create the list of expenses and set a listview
          if (dataSource.getAllExpenses().size() != 0) {
              rootView = inflater.inflate(R.layout.expandable_list, container, false);
  
              //prepare the list of Expenses to be put into an adapter
              preparedListData = prepareListData();
  
              //load the sorted list of lists of expense into the adapter
              listAdapter = new ExpandableListAdapter(context, preparedListData);
  
              expListView = (ExpandableListView) rootView.findViewById(R.id.lvExp);
              expListView.setAdapter(listAdapter);
              expListView.setOnChildClickListener(this);
          }
          //else show a layout saying the list is empty
          else {
              rootView = inflater.inflate(R.layout.expandable_list_empty, container, false);
          }
  
          return rootView;
      }
  </code></pre>