title: Reload ListView When Going Back to Fragment
body: <p>My app has a main activity that is a FragmentActivity with a TabHost. The first tab has a fragment with a list view that is populated with objects from Parse. When an item is selected from the list, a new activity is loaded with the details for that item and the user can mark the item as completed. When they return to the list view by hitting the back button, I want the data to be reloaded. How can I do that?</p>
  
  <p>MainActivity:</p>
  
  <pre><code>public class MainActivity extends FragmentActivity {
      private FragmentTabHost mTabHost;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mTabHost = (FragmentTabHost)findViewById(android.R.id.tabhost);
          mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
          mTabHost.addTab(mTabHost.newTabSpec("Unassigned").setIndicator("", getResources().getDrawable(R.drawable.unassigned)), UnassignedJobsFragment.class, null);
          mTabHost.addTab(mTabHost.newTabSpec("Assigned").setIndicator("", getResources().getDrawable(R.drawable.assigned)), AssignedJobsFragment.class, null);
          mTabHost.addTab(mTabHost.newTabSpec("Completed").setIndicator("", getResources().getDrawable(R.drawable.completed)), CompletedJobsFragment.class, null);
          mTabHost.addTab(mTabHost.newTabSpec("My Jobs").setIndicator("", getResources().getDrawable(R.drawable.myjobs)), MyJobsFragment.class, null);
          mTabHost.addTab(mTabHost.newTabSpec("Users").setIndicator("", getResources().getDrawable(R.drawable.users)), Users.class, null);
      }
  }
  </code></pre>
  
  <p>List Fragment:</p>
  
  <pre><code>public class UnassignedJobsFragment extends Fragment {
      private ImageButton mAddJobButton;
      ProgressBar mUnassignedProgress;
      ListView listView;
      List&lt;ParseObject&gt; object;
      List&lt;String&gt; objectIds;
      ArrayAdapter&lt;String&gt; adapter;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          View v = inflater.inflate(R.layout.fragment_unassigned, container, false);
          mAddJobButton = (ImageButton)v.findViewById(R.id.addJobButton);
          mUnassignedProgress = (ProgressBar)v.findViewById(R.id.unassignedProgress);
          listView = (ListView)v.findViewById(R.id.unassignedList);
          adapter = new ArrayAdapter&lt;String&gt;(getActivity().getApplicationContext(), R.layout.job_list_item);
          listView.setAdapter(adapter);
  
          listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  ParseObject selectedObject = object.get(position);
                  String objectId = objectIds.get(position);
                  String jobTitle = selectedObject.getString("job");
                  String worker = selectedObject.getString("worker");
                  String details = selectedObject.getString("details");
  
                  Date jobDate = selectedObject.getDate("date");
                  SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy hh:mm");
                  String dateString = dateFormat.format(jobDate);
  
                  Boolean accessedFromMyJobs = false;
  
                  Intent intent = new Intent(getActivity(), DetailActivity.class);
                  intent.putExtra("OBJECT_ID", objectId);
                  intent.putExtra("JOB_TITLE", jobTitle);
                  intent.putExtra("WORKER", worker);
                  intent.putExtra("DETAILS", details);
                  intent.putExtra("DATE", dateString);
                  intent.putExtra("FROM_MY_JOBS", accessedFromMyJobs);
                  startActivity(intent);
              }
          });
  
          ParseUser currentUser = ParseUser.getCurrentUser();
          String fullName = currentUser.get("Name").toString();
          if (fullName.equals("Cory Pollard") || fullName.equals("Richie Ray")) {
              mAddJobButton.setVisibility(View.VISIBLE);
          }
          else {
              mAddJobButton.setVisibility(View.GONE);
          }
  
          getJobs();
  
          return v;
      }
  
      public void getJobs() {
          mUnassignedProgress.setVisibility(View.VISIBLE);
  
          ParseQuery&lt;ParseObject&gt; query = ParseQuery.getQuery("Jobs");
          query.setLimit(1000);
          query.whereEqualTo("assigned", "no");
          query.findInBackground(new FindCallback&lt;ParseObject&gt;() {
              @Override
              public void done(List&lt;ParseObject&gt; parseObjects, ParseException e) {
                  if (e == null) {
                      object = new ArrayList&lt;ParseObject&gt;();
                      objectIds = new ArrayList&lt;String&gt;();
  
                      mUnassignedProgress.setVisibility(View.GONE);
  
                      for (ParseObject job : parseObjects) {
                          object.add(job);
                          objectIds.add(job.getObjectId().toString());
                      }
  
                      for (ParseObject job : object) {
                          adapter.add((String) job.getString("job"));
                      }
  
                      adapter.notifyDataSetChanged();
                  }
                  else {
                      mUnassignedProgress.setVisibility(View.GONE);
                      String exception = e.getMessage().toString();
                      Toast.makeText(getActivity().getApplicationContext(), exception, Toast.LENGTH_LONG);
                  }
              }
          });
      }
  }
  </code></pre>